Added three new toasters - private chat, group chat and chat lobby.

Fixed some utf8 issues in toasters and feeds.
Fixed german language.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5065 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-03-30 23:02:52 +00:00
parent 0778e8f691
commit 37986e00a3
35 changed files with 1335 additions and 239 deletions

View file

@ -126,8 +126,8 @@ static void updateItem(QTreeWidgetItem *item, ChatLobbyId id, const std::string
if(topic.empty())
{
item->setText(COLUMN_TOPIC, QObject::tr("[No topic provided]"));
item->setData(COLUMN_TOPIC, ROLE_SORT, QObject::tr("[No topic provided]"));
item->setText(COLUMN_TOPIC, qApp->translate("ChatLobbyWidget", "[No topic provided]"));
item->setData(COLUMN_TOPIC, ROLE_SORT, qApp->translate("ChatLobbyWidget", "[No topic provided]"));
}
else
{

View file

@ -847,3 +847,29 @@ void FriendsDialog::recommendFriends()
{
return instance ? instance->ui.tabWidget : NULL;
}
/*static*/ bool FriendsDialog::isGroupChatActive()
{
FriendsDialog *friendsDialog = dynamic_cast<FriendsDialog*>(MainWindow::getPage(MainWindow::Friends));
if (!friendsDialog) {
return false;
}
if (friendsDialog->ui.tabWidget->currentWidget() == friendsDialog->ui.groupChatTab) {
return true;
}
return false;
}
/*static*/ void FriendsDialog::groupChatActivate()
{
FriendsDialog *friendsDialog = dynamic_cast<FriendsDialog*>(MainWindow::getPage(MainWindow::Friends));
if (!friendsDialog) {
return;
}
MainWindow::showWindow(MainWindow::Friends);
friendsDialog->ui.tabWidget->setCurrentWidget(friendsDialog->ui.groupChatTab);
friendsDialog->ui.lineEdit->setFocus();
}

View file

@ -47,6 +47,8 @@ public:
virtual void updateDisplay() ; // overloaded from RsAutoUpdatePage
static ChatTabWidget *getTabWidget();
static bool isGroupChatActive();
static void groupChatActivate();
public slots:

View file

@ -817,7 +817,7 @@ p, li { white-space: pre-wrap; }
<property name="tabsClosable">
<bool>true</bool>
</property>
<widget class="QWidget" name="tab">
<widget class="QWidget" name="groupChatTab">
<attribute name="title">
<string>Group Chat</string>
</attribute>

View file

@ -947,6 +947,72 @@ void MainWindow::addAction(QAction *action, const char *slot)
connect(action, SIGNAL(triggered()), this, slot);
}
#ifdef WINDOWS_SYS
//void SetForegroundWindowInternal(HWND hWnd)
//{
// if (!::IsWindow(hWnd)) return;
// // relation time of SetForegroundWindow lock
// DWORD lockTimeOut = 0;
// HWND hCurrWnd = ::GetForegroundWindow();
// DWORD dwThisTID = ::GetCurrentThreadId(),
// dwCurrTID = ::GetWindowThreadProcessId(hCurrWnd,0);
// // we need to bypass some limitations from Microsoft :)
// if (dwThisTID != dwCurrTID) {
// ::AttachThreadInput(dwThisTID, dwCurrTID, TRUE);
// ::SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT,0,&lockTimeOut,0);
// ::SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,0,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
// ::AllowSetForegroundWindow(ASFW_ANY);
// }
// ::SetForegroundWindow(hWnd);
// if(dwThisTID != dwCurrTID) {
// ::SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,(PVOID)lockTimeOut,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
// ::AttachThreadInput(dwThisTID, dwCurrTID, FALSE);
// }
//}
void SetForegroundWindowInternal(HWND hWnd)
{
if (!::IsWindow(hWnd)) return;
BYTE keyState[256] = {0};
// to unlock SetForegroundWindow we need to imitate Alt pressing
if (::GetKeyboardState((LPBYTE)&keyState)) {
if(!(keyState[VK_MENU] & 0x80)) {
::keybd_event(VK_MENU, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
}
}
::SetForegroundWindow(hWnd);
if (::GetKeyboardState((LPBYTE)&keyState)) {
if(!(keyState[VK_MENU] & 0x80)) {
::keybd_event(VK_MENU, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
}
}
}
#endif
/*static*/ void MainWindow::raiseWindow()
{
if (_instance == NULL) {
return;
}
/* Show the dialog. */
_instance->show();
_instance->raise();
#ifdef WINDOWS_SYS
SetForegroundWindowInternal(_instance->winId());
#endif
}
/** Shows the MainWindow with focus set to the given page. */
/*static*/ void MainWindow::showWindow(Page page)
{
@ -955,7 +1021,7 @@ void MainWindow::addAction(QAction *action, const char *slot)
}
/* Show the dialog. */
_instance->show();
raiseWindow();
/* Set the focus to the specified page. */
activatePage (page);
}

View file

@ -93,6 +93,7 @@ public:
/** Destructor. */
~MainWindow();
static void raiseWindow();
/** Shows the MainWindow dialog with focus set to the given page. */
static void showWindow(Page page);
/** Set focus to the given page. */

View file

@ -27,6 +27,7 @@
#include "ChatTabWidget.h"
#include "gui/settings/rsharesettings.h"
#include "gui/settings/RsharePeerSettings.h"
#include "gui/MainWindow.h"
#include "gui/FriendsDialog.h"
#include <retroshare/rsnotify.h>
@ -219,6 +220,7 @@ bool ChatLobbyDialog::canClose()
void ChatLobbyDialog::showDialog(uint chatflags)
{
if (chatflags & RS_CHAT_FOCUS) {
MainWindow::showWindow(MainWindow::Friends);
ChatTabWidget *tabWidget = FriendsDialog::getTabWidget();
if (tabWidget) {
tabWidget->setCurrentWidget(this);

View file

@ -331,7 +331,7 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime
if (incoming && chatType == TYPE_NORMAL) {
emit newMessage(this);
if (!isVisible() || (window() && (!window()->isActiveWindow() || window()->isMinimized()))) {
if (!isActive()) {
newMessages = true;
}
@ -339,6 +339,15 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime
}
}
bool ChatWidget::isActive()
{
if (!isVisible() || (window() && (!window()->isActiveWindow() || window()->isMinimized()))) {
return false;
}
return true;
}
void ChatWidget::pasteLink()
{
std::cerr << "In paste link" << std::endl;

View file

@ -75,6 +75,8 @@ public:
void addChatButton(QPushButton *button) ;
bool isActive();
private slots:
void clearChatHistory();
void deleteChatHistory();

View file

@ -36,12 +36,6 @@
</property>
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Arial</family>

View file

@ -146,7 +146,7 @@ void ChatMsgItem::insertChat(const std::string &message)
QString timestamp = QDateTime::currentDateTime().toString("hh:mm:ss");
timestampLabel->setText(timestamp);
QString formatMsg = QString::fromStdString(message);
QString formatMsg = QString::fromUtf8(message.c_str());
unsigned int formatFlag = RSHTML_FORMATTEXT_EMBED_LINKS;

View file

@ -27,12 +27,6 @@
#include "notifyqt.h"
#include <retroshare/rsnotify.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsphoto.h>
#include <retroshare/rsmsgs.h>
#ifdef TURTLE_HOPPING
#include <retroshare/rsturtle.h>
#endif
#include "RsAutoUpdatePage.h"
@ -41,8 +35,14 @@
#include "toaster/OnlineToaster.h"
#include "toaster/MessageToaster.h"
#include "toaster/DownloadToaster.h"
#include "toaster/ChatToaster.h"
#include "toaster/GroupChatToaster.h"
#include "toaster/ChatLobbyToaster.h"
#endif // MINIMAL_RSGUI
#include "chat/ChatDialog.h"
#include "chat/ChatWidget.h"
#include "FriendsDialog.h"
#include "gui/settings/rsharesettings.h"
#include "SoundManager.h"
@ -468,21 +468,12 @@ void NotifyQt::UpdateGUI()
/* You can set timeToShow, timeToLive and timeToHide or can leave the standard */
Toaster *toaster = NULL;
/* id the name */
QString name;
if (type == RS_POPUP_DOWNLOAD) {
/* id = file hash */
} else {
name = QString::fromUtf8(rsPeers->getPeerName(id).c_str());
}
switch(type)
{
case RS_POPUP_MSG:
if (popupflags & RS_POPUP_MSG)
{
toaster = new Toaster(new MessageToaster(name, QString::fromUtf8(title.c_str()), QString::fromStdString(msg)));
toaster = new Toaster(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
}
break;
case RS_POPUP_CONNECT:
@ -490,15 +481,55 @@ void NotifyQt::UpdateGUI()
if (popupflags & RS_POPUP_CONNECT)
{
toaster = new Toaster(new OnlineToaster(id, name));
toaster = new Toaster(new OnlineToaster(id));
}
break;
case RS_POPUP_DOWNLOAD:
if (popupflags & RS_POPUP_DOWNLOAD)
{
/* id = file hash */
toaster = new Toaster(new DownloadToaster(id, QString::fromUtf8(title.c_str())));
}
break;
case RS_POPUP_CHAT:
if (popupflags & RS_POPUP_CHAT)
{
ChatDialog *chatDialog = ChatDialog::getChat(id, 0);
ChatWidget *chatWidget;
if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) {
// do not show when active
break;
}
toaster = new Toaster(new ChatToaster(id, QString::fromUtf8(msg.c_str())));
}
break;
case RS_POPUP_GROUPCHAT:
if (popupflags & RS_POPUP_GROUPCHAT)
{
MainWindow *mainWindow = MainWindow::getInstance();
if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized()) {
if (MainWindow::getActivatePage() == MainWindow::Friends) {
if (FriendsDialog::isGroupChatActive()) {
// do not show when active
break;
}
}
}
toaster = new Toaster(new GroupChatToaster(id, QString::fromUtf8(msg.c_str())));
}
break;
case RS_POPUP_CHATLOBBY:
if (popupflags & RS_POPUP_CHATLOBBY)
{
ChatDialog *chatDialog = ChatDialog::getChat(id, 0);
ChatWidget *chatWidget;
if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) {
// do not show when active
break;
}
toaster = new Toaster(new ChatLobbyToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
}
break;
}
if (toaster) {

View file

@ -69,6 +69,12 @@ NotifyPage::save(QString &/*errmsg*/)
notifyflags |= RS_POPUP_MSG;
if (ui.popup_DownloadFinished->isChecked())
notifyflags |= RS_POPUP_DOWNLOAD;
if (ui.popup_PrivateChat->isChecked())
notifyflags |= RS_POPUP_CHAT;
if (ui.popup_GroupChat->isChecked())
notifyflags |= RS_POPUP_GROUPCHAT;
if (ui.popup_ChatLobby->isChecked())
notifyflags |= RS_POPUP_CHATLOBBY;
if (ui.notify_Peers->isChecked())
newsflags |= RS_FEED_TYPE_PEER;
@ -151,6 +157,9 @@ void NotifyPage::load()
ui.popup_Connect->setChecked(notifyflags & RS_POPUP_CONNECT);
ui.popup_NewMsg->setChecked(notifyflags & RS_POPUP_MSG);
ui.popup_DownloadFinished->setChecked(notifyflags & RS_POPUP_DOWNLOAD);
ui.popup_PrivateChat->setChecked(notifyflags & RS_POPUP_CHAT);
ui.popup_GroupChat->setChecked(notifyflags & RS_POPUP_GROUPCHAT);
ui.popup_ChatLobby->setChecked(notifyflags & RS_POPUP_CHATLOBBY);
ui.notify_Peers->setChecked(newsflags & RS_FEED_TYPE_PEER);
ui.notify_Channels->setChecked(newsflags & RS_FEED_TYPE_CHAN);

View file

@ -593,7 +593,7 @@
<item row="0" column="0">
<widget class="QCheckBox" name="trayNotify_PrivateChat">
<property name="text">
<string>Private Message</string>
<string>Private Chat</string>
</property>
</widget>
</item>
@ -715,6 +715,27 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="popup_PrivateChat">
<property name="text">
<string>Private Chat</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="popup_GroupChat">
<property name="text">
<string>Group Chat</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="popup_ChatLobby">
<property name="text">
<string>Chat Lobby</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">

View file

@ -0,0 +1,62 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 RetroShare Team
*
* 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 "ChatLobbyToaster.h"
#include "gui/chat/ChatDialog.h"
#include "gui/chat/HandleRichText.h"
#include <retroshare/rsmsgs.h>
ChatLobbyToaster::ChatLobbyToaster(const std::string &peerId, const QString &name, const QString &message) : QWidget(NULL)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
this->peerId = peerId;
connect(ui.chatButton, SIGNAL(clicked()), SLOT(chatButtonSlot()));
connect(ui.closeButton, SIGNAL(clicked()), SLOT(hide()));
/* set informations */
ui.messageLabel->setText(RsHtml::formatText(message, RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
QString lobbyName = name;
std::list<ChatLobbyInfo> linfos;
rsMsgs->getChatLobbyList(linfos);
ChatLobbyId lobbyId;
if (rsMsgs->isLobbyId(peerId, lobbyId)) {
for (std::list<ChatLobbyInfo>::const_iterator it(linfos.begin()); it != linfos.end(); ++it) {
if ((*it).lobby_id == lobbyId) {
lobbyName += "@" + QString::fromUtf8((*it).lobby_name.c_str());
break;
}
}
}
ui.nameLabel->setText(lobbyName);
}
void ChatLobbyToaster::chatButtonSlot()
{
ChatDialog::chatFriend(peerId);
hide();
}

View file

@ -0,0 +1,49 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 RetroShare Team
*
* 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 CHATLOBBYTOASTER_H
#define CHATLOBBYTOASTER_H
#include "ui_ChatLobbyToaster.h"
/**
* Shows a toaster when a chat is incoming.
*
*
*/
class ChatLobbyToaster : public QWidget
{
Q_OBJECT
public:
ChatLobbyToaster(const std::string &peerId, const QString &name, const QString &message);
private slots:
void chatButtonSlot();
private:
std::string peerId;
/** Qt Designer generated object */
Ui::ChatLobbyToaster ui;
};
#endif //CHATLOBBYTOASTER_H

View file

@ -0,0 +1,208 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChatLobbyToaster</class>
<widget class="QWidget" name="ChatLobbyToaster">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>100</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>100</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>100</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="windowFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</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">
<layout class="QGridLayout" name="_2">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="3">
<widget class="QPushButton" name="closeButton">
<property name="minimumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/closenormal.png</normaloff>:/images/closenormal.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="nameLabel">
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Name</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/rstray3.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="_3">
<property name="leftMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QPushButton" name="chatButton">
<property name="font">
<font/>
</property>
<property name="text">
<string>Show Chat Lobby</string>
</property>
</widget>
</item>
<item row="1" column="1" rowspan="2">
<widget class="QLabel" name="messageLabel">
<property name="maximumSize">
<size>
<width>220</width>
<height>47</height>
</size>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="3">
<widget class="QLabel" name="avatar">
<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::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/user/agt_forum64.png</pixmap>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -0,0 +1,49 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 RetroShare Team
*
* 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 "ChatToaster.h"
#include "gui/chat/ChatDialog.h"
#include "gui/chat/HandleRichText.h"
#include <retroshare/rspeers.h>
ChatToaster::ChatToaster(const std::string &peerId, const QString &message) : QWidget(NULL)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
this->peerId = peerId;
connect(ui.chatButton, SIGNAL(clicked()), SLOT(chatButtonSlot()));
connect(ui.closeButton, SIGNAL(clicked()), SLOT(hide()));
/* set informations */
ui.messageLabel->setText(RsHtml::formatText(message, RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
ui.nameLabel->setText(QString::fromUtf8(rsPeers->getPeerName(peerId).c_str()));
ui.avatarWidget->setFrameType(AvatarWidget::STATUS_FRAME);
ui.avatarWidget->setId(peerId, false);
}
void ChatToaster::chatButtonSlot()
{
ChatDialog::chatFriend(peerId);
hide();
}

View file

@ -0,0 +1,49 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 RetroShare Team
*
* 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 CHATTOASTER_H
#define CHATTOASTER_H
#include "ui_ChatToaster.h"
/**
* Shows a toaster when a chat is incoming.
*
*
*/
class ChatToaster : public QWidget
{
Q_OBJECT
public:
ChatToaster(const std::string &peerId, const QString &message);
private slots:
void chatButtonSlot();
private:
std::string peerId;
/** Qt Designer generated object */
Ui::ChatToaster ui;
};
#endif //CHATTOASTER_H

View file

@ -0,0 +1,207 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChatToaster</class>
<widget class="QWidget" name="ChatToaster">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>102</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>100</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>102</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="windowFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</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">
<layout class="QGridLayout" name="_2">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="3">
<widget class="QPushButton" name="closeButton">
<property name="minimumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/closenormal.png</normaloff>:/images/closenormal.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QLabel" name="nameLabel">
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Name</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/rstray3.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="_3">
<property name="leftMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QPushButton" name="chatButton">
<property name="font">
<font/>
</property>
<property name="text">
<string>Show Chat</string>
</property>
</widget>
</item>
<item row="1" column="1" rowspan="2">
<widget class="QLabel" name="messageLabel">
<property name="maximumSize">
<size>
<width>220</width>
<height>47</height>
</size>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="3">
<widget class="AvatarWidget" name="avatarWidget" native="true">
<property name="minimumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>AvatarWidget</class>
<extends>QWidget</extends>
<header>gui/common/AvatarWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -0,0 +1,48 @@
/*
* RetroShare
* Copyright (C) 2012 RetroShare Team
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "GroupChatToaster.h"
#include "gui/FriendsDialog.h"
#include "gui/chat/HandleRichText.h"
#include <retroshare/rspeers.h>
GroupChatToaster::GroupChatToaster(const std::string &peerId, const QString &message) : QWidget(NULL)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
this->peerId = peerId;
connect(ui.chatButton, SIGNAL(clicked()), SLOT(chatButtonSlot()));
connect(ui.closeButton, SIGNAL(clicked()), SLOT(hide()));
/* set informations */
ui.messageLabel->setText(RsHtml::formatText(message, RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
ui.nameLabel->setText(QString::fromUtf8(rsPeers->getPeerName(peerId).c_str()));
ui.avatarWidget->setFrameType(AvatarWidget::STATUS_FRAME);
ui.avatarWidget->setDefaultAvatar(":/images/user/personal64.png");
ui.avatarWidget->setId(peerId, false);
}
void GroupChatToaster::chatButtonSlot()
{
FriendsDialog::groupChatActivate();
hide();
}

View file

@ -0,0 +1,47 @@
/*
* RetroShare
* Copyright (C) 2012 RetroShare Team
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef GROUPCHATTOASTER_H
#define GROUPCHATTOASTER_H
#include "ui_GroupChatToaster.h"
/**
* Shows a toaster when friend is GroupChat .
*
*
*/
class GroupChatToaster : public QWidget
{
Q_OBJECT
public:
GroupChatToaster(const std::string &peerId, const QString &message);
private slots:
void chatButtonSlot();
private:
std::string peerId;
/** Qt Designer generated object */
Ui::GroupChatToaster ui;
};
#endif //GROUPCHATTOASTER_H

View file

@ -0,0 +1,216 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GroupChatToaster</class>
<widget class="QWidget" name="GroupChatToaster">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>100</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>100</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>100</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="windowFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</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">
<layout class="QGridLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="3">
<widget class="QPushButton" name="closeButton">
<property name="minimumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/closenormal.png</normaloff>:/images/closenormal.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="nameLabel">
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Name</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/rstray3.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QGridLayout">
<property name="leftMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0" rowspan="3">
<widget class="AvatarWidget" name="avatarWidget" native="true">
<property name="minimumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1" rowspan="2">
<widget class="QLabel" name="messageLabel">
<property name="maximumSize">
<size>
<width>220</width>
<height>47</height>
</size>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="chatButton">
<property name="font">
<font/>
</property>
<property name="text">
<string>Show Group Chat</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>AvatarWidget</class>
<extends>QWidget</extends>
<header>gui/common/AvatarWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>closeButton</tabstop>
</tabstops>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -20,7 +20,9 @@
#include "MessageToaster.h"
#include "../MainWindow.h"
MessageToaster::MessageToaster(const QString &name, const QString &title, const QString &message) : QWidget(NULL)
#include <retroshare/rspeers.h>
MessageToaster::MessageToaster(const std::string &peerId, const QString &title, const QString &message) : QWidget(NULL)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
@ -35,7 +37,7 @@ MessageToaster::MessageToaster(const QString &name, const QString &title, const
ui.subjectline->setToolTip(title);
ui.contentBrowser->setText(message);
ui.contentBrowser->setToolTip(message);
ui.lblTitle->setText(ui.lblTitle->text() + " " + name);
ui.lblTitle->setText(ui.lblTitle->text() + " " + QString::fromUtf8(rsPeers->getPeerName(peerId).c_str()));
}
void MessageToaster::openmessageClicked()

View file

@ -33,7 +33,7 @@ class MessageToaster : public QWidget
Q_OBJECT
public:
MessageToaster(const QString &name, const QString &title, const QString &message);
MessageToaster(const std::string &peerId, const QString &title, const QString &message);
private slots:
void openmessageClicked();

View file

@ -18,12 +18,12 @@
*/
#include "OnlineToaster.h"
#include "gui/settings/rsharesettings.h"
#include "gui/chat/ChatDialog.h"
#include "util/WidgetBackgroundImage.h"
#include "gui/common/AvatarDefs.h"
OnlineToaster::OnlineToaster(const std::string &peerId, const QString &name) : QWidget(NULL)
#include <retroshare/rspeers.h>
OnlineToaster::OnlineToaster(const std::string &peerId) : QWidget(NULL)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
@ -35,11 +35,9 @@ OnlineToaster::OnlineToaster(const std::string &peerId, const QString &name) : Q
connect(ui.closeButton, SIGNAL(clicked()), SLOT(hide()));
/* set informations */
ui.messageLabel->setText(name);
QPixmap avatar;
AvatarDefs::getAvatarFromSslId(peerId, avatar, ":/images/user/personal64.png");
ui.pixmaplabel->setPixmap(avatar);
ui.messageLabel->setText(QString::fromUtf8(rsPeers->getPeerName(peerId).c_str()));
ui.avatarWidget->setFrameType(AvatarWidget::STATUS_FRAME);
ui.avatarWidget->setId(peerId, false);
WidgetBackgroundImage::setBackgroundImage(ui.windowFrame, ":images/toaster/backgroundtoaster.png", WidgetBackgroundImage::AdjustNone);
}

View file

@ -32,7 +32,7 @@ class OnlineToaster : public QWidget
Q_OBJECT
public:
OnlineToaster(const std::string &peerId, const QString &name);
OnlineToaster(const std::string &peerId);
private slots:
void chatButtonSlot();

View file

@ -162,37 +162,6 @@
</property>
</widget>
</item>
<item row="0" column="0" rowspan="4">
<widget class="QLabel" name="pixmaplabel">
<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="styleSheet">
<string notr="true">QLabel#pixmaplabel{
border: 2px solid #238;
border-radius: 4px;}
</string>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/user/personal64.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="messageButton">
<property name="font">
@ -222,6 +191,22 @@ border-radius: 4px;}
</property>
</spacer>
</item>
<item row="0" column="0" rowspan="4">
<widget class="AvatarWidget" name="avatarWidget" native="true">
<property name="minimumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
@ -242,6 +227,14 @@ border-radius: 4px;}
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>AvatarWidget</class>
<extends>QWidget</extends>
<header>gui/common/AvatarWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>closeButton</tabstop>
</tabstops>