removed old Chat Window experiments

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@455 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2008-03-31 21:56:23 +00:00
parent 2cb92f2d5a
commit 852e7cd04f
14 changed files with 0 additions and 2181 deletions

View File

@ -1,126 +0,0 @@
<ui version="4.0" >
<class>AvatarFrame</class>
<widget class="QWidget" name="AvatarFrame" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>88</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QFrame" name="remoteAvatarFrame" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>70</width>
<height>16</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape" >
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QFrame" name="userAvatarFrame" >
<property name="minimumSize" >
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="frameShape" >
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>0</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="userAvatar" >
<property name="minimumSize" >
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="text" >
<string/>
</property>
<property name="pixmap" >
<pixmap/>
</property>
<property name="scaledContents" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../wengophone.qrc" />
</resources>
<connections/>
</ui>

View File

@ -1,74 +0,0 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>AvatarWidget</class>
<widget class="QWidget" name="AvatarWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>120</width>
<height>126</height>
</rect>
</property>
<property name="minimumSize" >
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>4</number>
</property>
<item row="1" column="0" >
<widget class="QLabel" name="nicknameLabel" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="pictureLabel" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>1</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string/>
</property>
<property name="scaledContents" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources>
<include location="../../wengophone.qrc" />
</resources>
<connections/>
</ui>

View File

@ -1,94 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006,2007 crypton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "ChatAvatarFrame.h"
#include "ChatAvatarWidget.h"
#include <QtGui/QtGui>
#include <stdio.h>
ChatAvatarFrame::ChatAvatarFrame(QWidget * parent)
: QWidget(parent) {
ui.setupUi(this);
setMinimumWidth(70);
QGridLayout * glayout = dynamic_cast<QGridLayout *>(ui.remoteAvatarFrame->layout());
glayout->setSpacing(0);
glayout->setMargin(0);
}
void ChatAvatarFrame::setUserPixmap(QPixmap pixmap) {
QPixmap background = QPixmap(":images/avatar_background.png");
if (!pixmap.isNull()) {
QPainter painter(&background);
painter.drawPixmap(5, 5, pixmap.scaled(60, 60, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
painter.end();
ui.userAvatar->setPixmap(background);
} else {
ui.userAvatar->setPixmap(background);
}
}
void ChatAvatarFrame::addRemoteContact(const QString & id, const QString & displayName, const QString & contactId, QPixmap avatar) {
if (!_contactIdList.indexOf(id)) {
return;
} else {
_contactIdList.append(id);
}
ChatAvatarWidget * avatarWidget = new ChatAvatarWidget(
ui.remoteAvatarFrame, id, avatar, displayName, contactId, ChatAvatarWidget::BIG);
avatarWidget->setupPixmap(avatar);
_widgetList.append(avatarWidget);
QGridLayout * glayout = dynamic_cast<QGridLayout *>(ui.remoteAvatarFrame->layout());
glayout->addWidget(avatarWidget, glayout->count(), 0);
ui.remoteAvatarFrame->setMinimumSize(0, glayout->count() * 70);
}
void ChatAvatarFrame::removeRemoteContact(const QString & contactId) {
for (int i = 0; i < _widgetList.size(); i++) {
if (_widgetList[i]->getContactId() == contactId) {
QGridLayout * glayout = dynamic_cast<QGridLayout *>(ui.remoteAvatarFrame->layout());
glayout->removeWidget(_widgetList[i]);
glayout->update();
delete _widgetList[i];
_widgetList.removeAt(i);
}
}
_contactIdList.removeAll(contactId);
}
void ChatAvatarFrame::updateContact(const QString & id, QPixmap avatar, const QString & displayName) {
for(int i = 0; i < _widgetList.size(); i++) {
ChatAvatarWidget * chatAvatarWidget = _widgetList[i];
if (chatAvatarWidget->getContactId() == id) {
chatAvatarWidget->setupPixmap(avatar);
chatAvatarWidget->setToolTip(displayName);
}
}
}

View File

@ -1,62 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006,2007 crypton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef CHATAVATARFRAME_H
#define CHATAVATARFRAME_H
#include "ui_AvatarFrame.h"
#include <QtGui/QWidget>
#include <QtCore/QList>
#include <QtCore/QStringList>
class QHBoxLayout;
class ChatAvatarWidget;
class ChatAvatarFrame : public QWidget {
Q_OBJECT
public:
ChatAvatarFrame(QWidget * parent);
void setUserPixmap(QPixmap pixmap);
void addRemoteContact(const QString & id, const QString & displayName, const QString & contactId, QPixmap avatar);
void removeRemoteContact(const QString & contactId);
void updateContact(const QString & id, QPixmap avatar, const QString & displayName);
private:
typedef QList<ChatAvatarWidget*> WidgetList;
WidgetList _widgetList;
QVBoxLayout * _layout;
Ui::AvatarFrame ui;
QStringList _contactIdList;
};
#endif //CHATAVATARFRAME_H

View File

@ -1,110 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006,2007 crypton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "ChatAvatarWidget.h"
#include <QtGui/QtGui>
//#include <profile/AvatarList.h>
ChatAvatarWidget::ChatAvatarWidget(QWidget * parent, const QString & id,
QPixmap picture, const QString & nickname, const QString & contactId, OWPictureMode pmode, NicknameMode nmode)
: QWidget(parent), _pictureMode(pmode), _nicknameMode(nmode), _contactId(id) {
ui.setupUi(this);
//setupPixmap(picture);
setToolTip(nickname);
//setupNickname(contactId);
/*
if (_nicknameMode != NONE) {
setupNickname(nickname);
} else {
_ui.nicknameLabel->hide();
}*/
}
void ChatAvatarWidget::setupPixmap(QPixmap pixmap) {
//TODO:: resize fond_avatar.png
QPixmap background = QPixmap(":/images/avatar_background.png");
QPixmap defaultAvatar = QPixmap(":/images/nopic.png");
//QPixmap defaultAvatar(QString::fromStdString(AvatarList::getInstance().getDefaultAvatar().getFullPath()));
QPainter painter(&background);
if (!pixmap.isNull()) {
switch (_pictureMode) {
case HUGE:
painter.drawPixmap(0, 0, pixmap.scaled(96, 96, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
ui.pictureLabel->resize(96, 96);
setMinimumSize(96, 96);
break;
case BIG:
painter.drawPixmap(5, 5, pixmap.scaled(60, 60, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
ui.pictureLabel->resize(70, 70);
setMinimumSize(70, 70);
break;
case MEDIUM:
painter.drawPixmap(0, 0, pixmap.scaled(48, 48, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
ui.pictureLabel->resize(48, 48);
setMinimumSize(48, 48);
break;
case SMALL:
painter.drawPixmap(0, 0, pixmap.scaled(24, 24, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
ui.pictureLabel->resize(24, 24);
setMinimumSize(24, 24);
break;
case TINY:
painter.drawPixmap(0, 0, pixmap.scaled(12, 12, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
ui.pictureLabel->resize(12, 12);
setMinimumSize(12, 12);
break;
//default:
//LOG_WARN("unknown picture mode: " + String::fromNumber(_pictureMode));
}
} else {
painter.drawPixmap(5, 5, defaultAvatar.scaled(60, 60, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
ui.pictureLabel->resize(70, 70);
setMinimumSize(70, 70);
}
painter.end();
ui.pictureLabel->setPixmap(background);
}
void ChatAvatarWidget::setupNickname(const QString & nickname) {
//TODO: limit string length
QFontMetrics fontMetrics(ui.nicknameLabel->font());
int width = 60;
QString temp;
for(int i = 0; i < nickname.length(); i++) {
if (fontMetrics.width(temp) > width) {
break;
}
temp += nickname[i];
}
ui.nicknameLabel->setText(temp);
}
void ChatAvatarWidget::setToolTip(const QString & nickname) {
ui.pictureLabel->setToolTip(nickname);
}

View File

@ -1,74 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006,2007 crypton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef CHATAVATARWIDGET_H
#define CHATAVATARWIDGET_H
#include "ui_AvatarWidget.h"
#include <QtGui/QWidget>
class ChatAvatarWidget : public QWidget {
Q_OBJECT
public:
enum OWPictureMode {
HUGE, // 96x96
BIG, // 60x60
MEDIUM, // 48x48
SMALL, // 24x24
TINY, // 12x12
};
enum NicknameMode {
RIGHT,
LEFT,
TOP,
BOTTOM,
NONE,
};
ChatAvatarWidget(QWidget * parent, const QString & id, QPixmap picture,
const QString & nickname, const QString & contactId, OWPictureMode pmode = SMALL, NicknameMode nmode = NONE);
const QString getContactId() {
return _contactId;
}
void setupPixmap(QPixmap pixmap);
void setToolTip(const QString & nickname);
private:
void setupNickname(const QString & nickname);
OWPictureMode _pictureMode;
NicknameMode _nicknameMode;
QString _contactId;
Ui::AvatarWidget ui;
};
#endif //CHATAVATARWIDGET_H

View File

@ -1,230 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QtGui>
#include "rshare.h"
#include "ChatWindow.h"
#include "config/gconfig.h"
#include "ChatAvatarFrame.h"
#include "util/Widget.h"
#include <QTextCodec>
#include <QTextEdit>
#include <QToolBar>
#include <QTextCursor>
#include <QTextList>
#include <QtTest/QTest>
/** Default constructor */
ChatWindow::ChatWindow(QWidget *parent)
: QMainWindow(parent)
{
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
GConfig config;
config.loadWidgetInformation(this);
_isAvatarFrameOpened = true;
//creates sub widgets
_avatarFrame = new ChatAvatarFrame(this);
////
connect(ui.lineEdit, SIGNAL(returnPressed( ) ), this, SLOT(sendChat( ) ));
connect(ui.colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
connect(ui.textboldButton, SIGNAL(clicked()), this, SLOT(textBold()));
connect(ui.textunderlineButton, SIGNAL(clicked()), this, SLOT(textUnderline()));
connect(ui.textitalicButton, SIGNAL(clicked()), this, SLOT(textItalic()));
connect(ui.avatarFrameButton, SIGNAL(clicked()), SLOT(avatarFrameButtonClicked()));
addAvatarFrame();
}
/**
Overloads the default show() slot so we can set opacity*/
void
ChatWindow::show()
{
//loadSettings();
if(!this->isVisible()) {
QMainWindow::show();
}
}
void ChatWindow::closeEvent (QCloseEvent * event)
{
QMainWindow::closeEvent(event);
}
void ChatWindow::setColor()
{
QColor col = QColorDialog::getColor(Qt::green, this);
if (col.isValid()) {
ui.colorButton->setPalette(QPalette(col));
QTextCharFormat fmt;
fmt.setForeground(col);
mergeFormatOnWordOrSelection(fmt);
colorChanged(col);
}
}
void ChatWindow::textBold()
{
QTextCharFormat fmt;
fmt.setFontWeight(ui.textboldButton->isChecked() ? QFont::Bold : QFont::Normal);
mergeFormatOnWordOrSelection(fmt);
}
void ChatWindow::textUnderline()
{
QTextCharFormat fmt;
fmt.setFontUnderline(ui.textunderlineButton->isChecked());
mergeFormatOnWordOrSelection(fmt);
}
void ChatWindow::textItalic()
{
QTextCharFormat fmt;
fmt.setFontItalic(ui.textitalicButton->isChecked());
mergeFormatOnWordOrSelection(fmt);
}
void ChatWindow::currentCharFormatChanged(const QTextCharFormat &format)
{
fontChanged(format.font());
colorChanged(format.foreground().color());
}
void ChatWindow::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
{
QTextCursor cursor = ui.textBrowser->textCursor();
if (!cursor.hasSelection())
cursor.select(QTextCursor::WordUnderCursor);
cursor.mergeCharFormat(format);
ui.textBrowser->mergeCurrentCharFormat(format);
}
void ChatWindow::fontChanged(const QFont &f)
{
//comboFont->setCurrentIndex(comboFont->findText(QFontInfo(f).family()));
//comboSize->setCurrentIndex(comboSize->findText(QString::number(f.pointSize())));
ui.textboldButton->setChecked(f.bold());
ui.textunderlineButton->setChecked(f.italic());
ui.textitalicButton->setChecked(f.underline());
}
void ChatWindow::colorChanged(const QColor &c)
{
QPixmap pix(16, 16);
pix.fill(c);
ui.colorButton->setIcon(pix);
}
void ChatWindow::updateChat()
{
/* get chat off queue */
/* write it out */
}
void ChatWindow::addChatMsg()
{
}
void ChatWindow::sendChat()
{
}
void ChatWindow::avatarFrameButtonClicked() {
if (_isAvatarFrameOpened) {
removeAvatarFrame();
} else {
addAvatarFrame();
}
}
void ChatWindow::addAvatarFrame() {
QBoxLayout * glayout = dynamic_cast<QBoxLayout *>(layout());
_avatarFrame->setVisible(true);
//_avatarFrame->setMinimumSize(64, 0);
glayout->insertWidget(1, _avatarFrame);
_isAvatarFrameOpened = true;
ui.avatarFrameButton->setIcon(QIcon(":images/show_toolbox_frame.png"));
update();
}
void ChatWindow::removeAvatarFrame() {
QBoxLayout * glayout = dynamic_cast<QBoxLayout *>(layout());
_avatarFrame->setVisible(false);
_avatarFrame->setMinimumSize(0, 0);
glayout->removeWidget(_avatarFrame);
_isAvatarFrameOpened = false;
ui.avatarFrameButton->setIcon(QIcon(":images/hide_toolbox_frame.png"));
update();
}
void ChatWindow::updateUserAvatar() {
QPixmap pixmap;
//std::string myData = _cChatHandler.getCUserProfile().getUserProfile().getIcon().getData();
//pixmap.loadFromData((uchar *)myData.c_str(), myData.size());
_avatarFrame->setUserPixmap(pixmap);
}
//void ChatWindow::updateAvatarFrame() {
//}

View File

@ -1,106 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _CHATWINDOW_H
#define _CHATWINDOW_H
#include "ui_ChatWindow.h"
#include "rsiface/rsiface.h"
#include <QDialog>
class ChatAvatarFrame;
class QAction;
class QTextEdit;
class QTextCharFormat;
class RetroSyleLabel;
class ChatWindow : public QMainWindow
{
Q_OBJECT
public:
/** Default constructor */
ChatWindow(QWidget *parent = 0);
/** Default destructor */
void updateChat();
void addChatMsg();
public slots:
/** Overloaded QWidget.show */
void show();
protected:
void closeEvent (QCloseEvent * event);
private slots:
void setColor();
void textBold();
void textUnderline();
void textItalic();
void sendChat();
void currentCharFormatChanged(const QTextCharFormat &format);
void avatarFrameButtonClicked();
private:
void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
void fontChanged(const QFont &f);
void colorChanged(const QColor &c);
void addAvatarFrame();
void removeAvatarFrame();
//void updateAvatarFrame();
void updateUserAvatar();
bool _isAvatarFrameOpened;
ChatAvatarFrame * _avatarFrame;
QAction *actionTextBold;
QAction *actionTextUnderline;
QAction *actionTextItalic;
//std::string dialogId, dialogName;
//unsigned int lastChatTime;
//std::string lastChatName;
/** Qt Designer generated object */
Ui::ChatWindow ui;
};
#endif

View File

@ -1,282 +0,0 @@
<ui version="4.0" >
<class>ChatWindow</class>
<widget class="QMainWindow" name="ChatWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>487</width>
<height>395</height>
</rect>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget" >
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QSplitter" name="splitter" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="layoutWidget_3" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QTextBrowser" name="textBrowser" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="sizeIncrement" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>321</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3" >
<widget class="QPushButton" name="textitalicButton" >
<property name="minimumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="../images.qrc" >:/images/edit-underline.png</iconset>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QPushButton" name="textunderlineButton" >
<property name="minimumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="../images.qrc" >:/images/edit-italic.png</iconset>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QPushButton" name="textboldButton" >
<property name="minimumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="../images.qrc" >:/images/edit-bold.png</iconset>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="4" >
<widget class="QPushButton" name="colorButton" >
<property name="minimumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item rowspan="2" row="0" column="1" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="avatarFrameButton" >
<property name="minimumSize" >
<size>
<width>14</width>
<height>31</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>14</width>
<height>32</height>
</size>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="../images.qrc" >:/images/show_toolbox_frame.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>14</width>
<height>31</height>
</size>
</property>
<property name="checkable" >
<bool>false</bool>
</property>
<property name="autoRaise" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>16</width>
<height>509</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0" >
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item rowspan="2" row="0" column="0" >
<widget class="QTextEdit" name="lineEdit" />
</item>
<item row="0" column="1" >
<widget class="QPushButton" name="pushButton" >
<property name="text" >
<string>Send</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QPushButton" name="pushButton_2" >
<property name="text" >
<string>Search</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar" />
<widget class="QToolBar" name="toolBar" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<attribute name="toolBarArea" >
<number>4</number>
</attribute>
</widget>
</widget>
<tabstops>
<tabstop>lineEdit</tabstop>
<tabstop>textboldButton</tabstop>
<tabstop>textunderlineButton</tabstop>
<tabstop>textitalicButton</tabstop>
<tabstop>colorButton</tabstop>
<tabstop>pushButton</tabstop>
<tabstop>pushButton_2</tabstop>
<tabstop>textBrowser</tabstop>
<tabstop>avatarFrameButton</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -1,61 +0,0 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>UserFrame</class>
<widget class="QWidget" name="UserFrame" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>120</width>
<height>116</height>
</rect>
</property>
<property name="minimumSize" >
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>0</number>
</property>
<item row="0" column="0" >
<widget class="QFrame" name="frame" >
<property name="frameShape" >
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>0</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="avatarLabel" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>

View File

@ -1,419 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QtGui>
#include "rshare.h"
#include "ChatDialog.h"
#include "rsiface/rsiface.h"
#include "chat/PopupChatDialog.h"
#include "chat/ChatWindow.h"
#include <sstream>
#include <QTextCodec>
#include <QTextEdit>
#include <QToolBar>
#include <QTextCursor>
#include <QTextList>
#include <QContextMenuEvent>
#include <QMenu>
#include <QCursor>
#include <QPoint>
#include <QMouseEvent>
#include <QPixmap>
/** Constructor */
ChatDialog::ChatDialog(QWidget *parent)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect(ui.lineEdit, SIGNAL(returnPressed( ) ), this, SLOT(sendMsg( ) ));
connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(setColor()));
connect(ui.textboldChatButton, SIGNAL(clicked()), this, SLOT(textBold()));
connect(ui.textunderlineChatButton, SIGNAL(clicked()), this, SLOT(textUnderline()));
connect(ui.textitalicChatButton, SIGNAL(clicked()), this, SLOT(textItalic()));
connect( ui.msgSendList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgSendListCostumPopupMenu( QPoint ) ) );
// connect(ui.msgSendList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ),
// this, SLOT(toggleSendItem( QTreeWidgetItem *, int ) ));
loadInitMsg();
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
void ChatDialog::msgSendListCostumPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
privchatAct = new QAction(QIcon(), tr( "Chat" ), this );
connect( privchatAct , SIGNAL( triggered() ), this, SLOT( privchat() ) );
contextMnu.clear();
contextMnu.addAction( privchatAct);
contextMnu.exec( mevent->globalPos() );
}
int ChatDialog::loadInitMsg()
{
std::ostringstream out;
//out << std::endl;
//out << std::endl;
//out << std::endl;
out << "Welcome to Retroshare's group chat.";
out << std::endl;
out << std::endl;
QString txt = QString::fromStdString(out.str());
ui.msgText->setPlainText(txt);
ui.msgText->setTextColor(Qt::gray);
return 1;
}
void ChatDialog::insertChat()
{
rsiface->lockData(); /* Lock Interface */
/* get a link to the table */
QTextEdit *msgWidget = ui.msgText;
std::list<ChatInfo> newchat = rsiface->getChatNew();
std::list<ChatInfo>::iterator it;
rsiface->unlockData(); /* Unlock Interface */
static std::string lastChatName("");
static int lastChatTime = 0;
QString currenttxt = msgWidget->toPlainText();
/* determine how many spaces to add */
int n = msgWidget->width();
/* now spaces = (width - txt width) / (pixel / space)
*/
std::cerr << "Width is : " << n << std::endl;
n -= 256; /* 220 pixels for name */
if (n > 0)
{
n = 2 + n / 10;
}
else
{
n = 1;
}
std::cerr << "Space count : " << n << std::endl;
std::string spaces(" ");
/* add in lines at the bottom */
std::ostringstream out;
int ts = time(NULL);
for(it = newchat.begin(); it != newchat.end(); it++)
{
/* are they private? */
if (it->chatflags & RS_CHAT_PRIVATE)
{
ChatWindow *pcd = getPrivateChat(it->rsid, it->name, true);
pcd->addChatMsg(&(*it));
}
if ((it->name == lastChatName) && (ts - lastChatTime < 60))
{
/* no name */
}
else
{
for(int i = 0; i < n; i++)
{
out << spaces;
}
out << "<" << it -> name << " Said @" << ts << ">" << std::endl;
}
if (it->chatflags & RS_CHAT_PRIVATE)
out << "[P] ";
out << it -> msg << std::endl;
/*
*/
lastChatName = it -> name;
lastChatTime = ts;
}
QString extra = QString::fromStdString(out.str());
currenttxt += extra;
msgWidget->setPlainText(currenttxt);
std::cerr << " Added Text: " << std::endl;
std::cerr << out.str() << std::endl;
QScrollBar *qsb = msgWidget->verticalScrollBar();
qsb -> setValue(qsb->maximum());
}
void ChatDialog::sendMsg()
{
QLineEdit *lineWidget = ui.lineEdit;
ChatInfo ci;
ci.msg = lineWidget->text().toStdString();
ci.chatflags = RS_CHAT_PUBLIC;
rsicontrol -> ChatSend(ci);
lineWidget -> setText(QString(""));
/* redraw send list */
insertSendList();
}
void ChatDialog::insertSendList()
{
rsiface->lockData(); /* Lock Interface */
std::map<RsCertId,NeighbourInfo>::const_iterator it;
const std::map<RsCertId,NeighbourInfo> &friends =
rsiface->getFriendMap();
/* get a link to the table */
QTreeWidget *sendWidget = ui.msgSendList;
/* remove old items ??? */
sendWidget->clear();
sendWidget->setColumnCount(6);
QList<QTreeWidgetItem *> items;
for(it = friends.begin(); it != friends.end(); it++)
{
/* if offline, don't add */
if ((it -> second.connectString == "Online" ) ||
(it -> second.connectString == "Yourself"))
{
/* ok */
}
else
{
continue;
}
/* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
/* add all the labels */
/* (0) Person */
item -> setText(0, QString::fromStdString(it->second.name));
/* () Org */
item -> setText(1, QString::fromStdString(it->second.org));
/* () Location */
item -> setText(2, QString::fromStdString(it->second.loc));
/* () Country */
item -> setText(3, QString::fromStdString(it->second.country));
{
std::ostringstream out;
out << it->second.id;
item -> setText(4, QString::fromStdString(out.str()));
}
item -> setText(5, "Friend");
//item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
item -> setFlags(Qt::ItemIsUserCheckable);
item -> setCheckState(0, Qt::Checked);
/**** NOT SELECTABLE AT THE MOMENT
if (it ->second.inChat)
{
item -> setCheckState(0, Qt::Checked);
}
else
{
item -> setCheckState(0, Qt::Unchecked);
}
************/
/* add to the list */
items.append(item);
}
/* add the items in! */
sendWidget->insertTopLevelItems(0, items);
rsiface->unlockData(); /* UnLock Interface */
sendWidget->update(); /* update display */
}
/* to toggle the state */
void ChatDialog::toggleSendItem( QTreeWidgetItem *item, int col )
{
std::cerr << "ToggleSendItem()" << std::endl;
/* extract id */
std::string id = (item -> text(4)).toStdString();
/* get state */
bool inChat = (Qt::Checked == item -> checkState(0)); /* alway column 0 */
/* call control fns */
rsicontrol -> SetInChat(id, inChat);
return;
}
void ChatDialog::setColor()
{
QColor col = QColorDialog::getColor(Qt::green, this);
if (col.isValid()) {
ui.colorChatButton->setPalette(QPalette(col));
QTextCharFormat fmt;
fmt.setForeground(col);
mergeFormatOnWordOrSelection(fmt);
colorChanged(col);
}
}
void ChatDialog::textBold()
{
QTextCharFormat fmt;
fmt.setFontWeight(ui.textboldChatButton->isChecked() ? QFont::Bold : QFont::Normal);
mergeFormatOnWordOrSelection(fmt);
}
void ChatDialog::textUnderline()
{
QTextCharFormat fmt;
fmt.setFontUnderline(ui.textunderlineChatButton->isChecked());
mergeFormatOnWordOrSelection(fmt);
}
void ChatDialog::textItalic()
{
QTextCharFormat fmt;
fmt.setFontItalic(ui.textitalicChatButton->isChecked());
mergeFormatOnWordOrSelection(fmt);
}
void ChatDialog::currentCharFormatChanged(const QTextCharFormat &format)
{
fontChanged(format.font());
colorChanged(format.foreground().color());
}
void ChatDialog::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
{
QTextCursor cursor = ui.msgText->textCursor();
if (!cursor.hasSelection())
cursor.select(QTextCursor::WordUnderCursor);
cursor.mergeCharFormat(format);
ui.msgText->mergeCurrentCharFormat(format);
}
void ChatDialog::fontChanged(const QFont &f)
{
//comboFont->setCurrentIndex(comboFont->findText(QFontInfo(f).family()));
//comboSize->setCurrentIndex(comboSize->findText(QString::number(f.pointSize())));
ui.textboldChatButton->setChecked(f.bold());
ui.textunderlineChatButton->setChecked(f.italic());
ui.textitalicChatButton->setChecked(f.underline());
}
void ChatDialog::colorChanged(const QColor &c)
{
QPixmap pix(16, 16);
pix.fill(c);
ui.colorChatButton->setIcon(pix);
}
void ChatDialog::privchat()
{
}
ChatWindow *ChatDialog::getPrivateChat(std::string id, std::string name, bool show )
{
/* see if it exists already */
ChatWindow *popupchatdialog = NULL;
std::map<std::string, ChatWindow *>::iterator it;
if (chatDialogs.end() != (it = chatDialogs.find(id)))
{
/* exists already */
popupchatdialog = it->second;
}
else
{
popupchatdialog = new ChatWindow(id, name);
chatDialogs[id] = popupchatdialog;
}
if (show)
{
popupchatdialog->show();
}
return popupchatdialog;
}
void ChatDialog::clearOldChats()
{
/* nothing yet */
}

View File

@ -1,97 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _CHATDIALOG_H
#define _CHATDIALOG_H
#include "mainpage.h"
#include "ui_ChatDialog.h"
#include "chat/ChatWindow.h"
class QAction;
class QTextEdit;
class QTextCharFormat;
class ChatDialog : public MainPage
{
Q_OBJECT
public:
/** Default Constructor */
ChatDialog(QWidget *parent = 0);
/** Default Destructor */
void insertChat();
ChatWindow *getPrivateChat(std::string id, std::string name, bool show);
void clearOldChats();
int loadInitMsg();
private slots:
void toggleSendItem( QTreeWidgetItem *item, int col );
/** Create the context popup menu and it's submenus */
void msgSendListCostumPopupMenu( QPoint point );
void setColor();
void textBold();
void textUnderline();
void textItalic();
void currentCharFormatChanged(const QTextCharFormat &format);
void insertSendList();
void sendMsg();
void privchat();
private:
void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
void fontChanged(const QFont &f);
void colorChanged(const QColor &c);
QAction *actionTextBold;
QAction *actionTextUnderline;
QAction *actionTextItalic;
/** Define the popup menus for the Context menu */
QMenu* contextMnu;
/** Defines the actions for the context menu */
QAction* privchatAct;
QTreeView *msgSendList;
std::map<std::string, ChatWindow *> chatDialogs;
/** Qt Designer generated object */
Ui::ChatDialog ui;
};
#endif

View File

@ -1,340 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QtGui>
#include "rshare.h"
#include "ChatWindow.h"
#include "config/gconfig.h"
#include "ChatAvatarFrame.h"
#include <QTextCodec>
#include <QTextEdit>
#include <QToolBar>
#include <QTextCursor>
#include <QTextList>
/* Define the format used for displaying the date and time */
#define DATETIME_FMT "MMM dd hh:mm:ss"
#include <sstream>
/** Default constructor */
ChatWindow::ChatWindow(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);
GConfig config;
config.loadWidgetInformation(this);
_isAvatarFrameOpened = true;
//creates sub widgets
_avatarFrame = new QtChatAvatarFrame(this);
////
connect(ui.lineEdit, SIGNAL(returnPressed( ) ), this, SLOT(sendChat( ) ));
connect(ui.colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
connect(ui.textboldButton, SIGNAL(clicked()), this, SLOT(textBold()));
connect(ui.textunderlineButton, SIGNAL(clicked()), this, SLOT(textUnderline()));
connect(ui.textitalicButton, SIGNAL(clicked()), this, SLOT(textItalic()));
connect(ui.avatarFrameButton, SIGNAL(clicked()), SLOT(avatarFrameButtonClicked()));
addAvatarFrame();
// Create the status bar
std::ostringstream statusstr;
statusstr << "Chatting with: " << dialogName << " !!! " << id;
statusBar()->showMessage(QString::fromStdString(statusstr.str()));
ui.textBrowser->setOpenExternalLinks ( false );
}
/**
Overloads the default show() slot so we can set opacity*/
void
ChatWindow::show()
{
//loadSettings();
if(!this->isVisible()) {
QMainWindow::show();
}
}
void ChatWindow::closeEvent (QCloseEvent * event)
{
QMainWindow::closeEvent(event);
}
void ChatWindow::setColor()
{
QColor col = QColorDialog::getColor(Qt::green, this);
if (col.isValid()) {
ui.colorButton->setPalette(QPalette(col));
QTextCharFormat fmt;
fmt.setForeground(col);
mergeFormatOnWordOrSelection(fmt);
colorChanged(col);
}
}
void ChatWindow::textBold()
{
QTextCharFormat fmt;
fmt.setFontWeight(ui.textboldButton->isChecked() ? QFont::Bold : QFont::Normal);
mergeFormatOnWordOrSelection(fmt);
}
void ChatWindow::textUnderline()
{
QTextCharFormat fmt;
fmt.setFontUnderline(ui.textunderlineButton->isChecked());
mergeFormatOnWordOrSelection(fmt);
}
void ChatWindow::textItalic()
{
QTextCharFormat fmt;
fmt.setFontItalic(ui.textitalicButton->isChecked());
mergeFormatOnWordOrSelection(fmt);
}
void ChatWindow::currentCharFormatChanged(const QTextCharFormat &format)
{
fontChanged(format.font());
colorChanged(format.foreground().color());
}
void ChatWindow::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
{
QTextCursor cursor = ui.textBrowser->textCursor();
if (!cursor.hasSelection())
cursor.select(QTextCursor::WordUnderCursor);
cursor.mergeCharFormat(format);
ui.textBrowser->mergeCurrentCharFormat(format);
}
void ChatWindow::fontChanged(const QFont &f)
{
//comboFont->setCurrentIndex(comboFont->findText(QFontInfo(f).family()));
//comboSize->setCurrentIndex(comboSize->findText(QString::number(f.pointSize())));
ui.textboldButton->setChecked(f.bold());
ui.textunderlineButton->setChecked(f.italic());
ui.textitalicButton->setChecked(f.underline());
}
void ChatWindow::colorChanged(const QColor &c)
{
QPixmap pix(16, 16);
pix.fill(c);
ui.colorButton->setIcon(pix);
}
void ChatWindow::updateChat()
{
/* get chat off queue */
/* write it out */
}
void ChatWindow::addChatMsg(ChatInfo *ci)
{
QTextBrowser *msgWidget = ui.textBrowser;
QString currenttxt = msgWidget->toHtml();
/* determine how many spaces to add */
int n = msgWidget->width();
/* now spaces = (width - txt width) / (pixel / space)
*/
std::cerr << "Width is : " << n << std::endl;
n -= 256; /* 220 pixels for name */
if (n > 0)
{
n = 2 + n / 10;
}
else
{
n = 1;
}
std::cerr << "Space count : " << n << std::endl;
std::string spaces(" ");
/* add in lines at the bottom */
std::ostringstream out;
int ts = time(NULL);
if ((ci->name == lastChatName) && (ts - lastChatTime < 60))
{
/* no name */
}
else
{
for(int i = 0; i < n; i++)
{
out << spaces;
}
out << "[" << ci->name << " Said @" << ts << "]" << std::endl;
out << "<br>" << std::endl;
}
out << ci -> msg << std::endl;
lastChatTime = ts;
lastChatName = ci->name;
QString extra = QString::fromStdString(out.str());
currenttxt += extra;
msgWidget->setHtml(currenttxt);
std::cerr << " Added Text: " << std::endl;
std::cerr << out.str() << std::endl;
QScrollBar *qsb = msgWidget->verticalScrollBar();
qsb -> setValue(qsb->maximum());
}
void ChatWindow::sendChat()
{
QTextEdit *lineWidget = ui.lineEdit;
ChatInfo ci;
{
rsiface->lockData(); /* Lock Interface */
const RsConfig &conf = rsiface->getConfig();
ci.rsid = conf.ownId;
ci.name = conf.ownName;
rsiface->unlockData(); /* Unlock Interface */
}
ci.msg = lineWidget->documentTitle().toStdString();
ci.chatflags = RS_CHAT_PRIVATE;
addChatMsg(&ci);
/* put proper destination */
ci.rsid = dialogId;
ci.name = dialogName;
rsicontrol -> ChatSend(ci);
lineWidget -> setText(QString(""));
/* redraw send list */
}
void ChatWindow::avatarFrameButtonClicked() {
if (_isAvatarFrameOpened) {
removeAvatarFrame();
} else {
addAvatarFrame();
}
}
void ChatWindow::addAvatarFrame() {
QBoxLayout * glayout = dynamic_cast<QBoxLayout *>(layout());
_avatarFrame->setVisible(true);
//_avatarFrame->setMinimumSize(64, 0);
glayout->insertWidget(1, _avatarFrame);
_isAvatarFrameOpened = true;
ui.avatarFrameButton->setIcon(QIcon(":images/show_toolbox_frame.png"));
update();
}
void ChatWindow::removeAvatarFrame() {
QBoxLayout * glayout = dynamic_cast<QBoxLayout *>(layout());
_avatarFrame->setVisible(false);
_avatarFrame->setMinimumSize(0, 0);
glayout->removeWidget(_avatarFrame);
_isAvatarFrameOpened = false;
ui.avatarFrameButton->setIcon(QIcon(":images/hide_toolbox_frame.png"));
update();
}
void ChatWindow::updateUserAvatar() {
QPixmap pixmap;
//std::string myData = _cChatHandler.getCUserProfile().getUserProfile().getIcon().getData();
//pixmap.loadFromData((uchar *)myData.c_str(), myData.size());
_avatarFrame->setUserPixmap(pixmap);
}
//void ChatWindow::updateAvatarFrame() {
// QMutexLocker locker(&_mutex);
//QtContactList * qtContactList = _qtrs->getQtContactList();
//CContactList & cContactList = qtrsContactList->getCContactList();
//IMContactSet imContactSet = _imChatSession->getIMContactSet();
//IMContactSet::iterator it;
//for (it = imContactSet.begin(); it != imContactSet.end(); it++) {
//std::string contactId = cContactList.findContactThatOwns(*it);
//ContactProfile profile = cContactList.getContactProfile(contactId);
//std::string data = profile.getIcon().getData();
//QPixmap pixmap;
//pixmap.loadFromData((uchar *)data.c_str(), data.size());
//_avatarFrame->addRemoteContact(
//QString::fromStdString(contactId),
//QString::fromStdString(profile.getDisplayName()),
//QString::fromStdString((*it).getContactId()),
//pixmap
//);
//}
//}

View File

@ -1,106 +0,0 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _CHATWINDOW_H
#define _CHATWINDOW_H
#include "ui_ChatWindow.h"
#include "rsiface/rsiface.h"
#include <QDialog>
class ChatAvatarFrame;
class QAction;
class QTextEdit;
class QTextCharFormat;
class ChatWindow : public QMainWindow
{
Q_OBJECT
public:
/** Default constructor */
ChatWindow(std::string id, std::string name,
QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */
void updateChat();
void addChatMsg(ChatInfo *ci);
public slots:
/** Overloaded QWidget.show */
void show();
protected:
void closeEvent (QCloseEvent * event);
private slots:
void setColor();
void textBold();
void textUnderline();
void textItalic();
void sendChat();
void currentCharFormatChanged(const QTextCharFormat &format);
void avatarFrameButtonClicked();
private:
void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
void fontChanged(const QFont &f);
void colorChanged(const QColor &c);
void addAvatarFrame();
void removeAvatarFrame();
//void updateAvatarFrame();
void updateUserAvatar();
bool _isAvatarFrameOpened;
ChatAvatarFrame * _avatarFrame;
QAction *actionTextBold;
QAction *actionTextUnderline;
QAction *actionTextItalic;
std::string dialogId, dialogName;
unsigned int lastChatTime;
std::string lastChatName;
/** Qt Designer generated object */
Ui::ChatWindow ui;
};
#endif