mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-15 17:37:12 -05:00
MessengerWindow
- cleaned include files - changed menu for set the tree is decorated - new check for sort rows by state - saved the state of sort order, hide offline, sort by state and decorated state PopupChatWindow: - when setting "Grab Focus when chat arrives" not checked, the new chat window is opened minimized and flashed in taskbar reworked start private chat and message to friend from PeersDialog and MessengerWindow: - moved method for starting a private chat from PeersDialog and MessengerWindow to PopupChatDialog - moved method for sending a message to a friend from PeersDialog to MessageComposer - removed signal startChat fixed bug in MessengerWindow: - when peer is not online and private chat is not available, the message was send to the wrong peer (the current peer in PeersDialog) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3154 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
95c5c4b1a1
commit
e282a55164
File diff suppressed because it is too large
Load Diff
@ -21,139 +21,128 @@
|
|||||||
|
|
||||||
#ifndef _MESSENGERWINDOW_H
|
#ifndef _MESSENGERWINDOW_H
|
||||||
#define _MESSENGERWINDOW_H
|
#define _MESSENGERWINDOW_H
|
||||||
#include <QFileDialog>
|
|
||||||
|
|
||||||
#include "mainpage.h"
|
|
||||||
#include "ui_MessengerWindow.h"
|
#include "ui_MessengerWindow.h"
|
||||||
|
|
||||||
#include <gui/common/rwindow.h>
|
#include <gui/common/rwindow.h>
|
||||||
#include "chat/PopupChatDialog.h"
|
|
||||||
#include "RsAutoUpdatePage.h"
|
|
||||||
|
|
||||||
|
|
||||||
class LogoBar;
|
class LogoBar;
|
||||||
class PeersDialog;
|
class PeersDialog;
|
||||||
|
class PopupChatDialog;
|
||||||
|
|
||||||
class MessengerWindow : public RWindow
|
class MessengerWindow : public RWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
QPixmap picture;
|
||||||
PopupChatDialog *getPrivateChat(std::string id, std::string name, uint chatflags);
|
|
||||||
|
|
||||||
QPixmap picture;
|
|
||||||
|
|
||||||
static MessengerWindow* getInstance();
|
|
||||||
static void releaseInstance();
|
|
||||||
|
|
||||||
|
static MessengerWindow* getInstance();
|
||||||
|
static void releaseInstance();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
/** Called when this dialog is to be displayed */
|
||||||
|
void show();
|
||||||
|
void updateMessengerDisplay() ;
|
||||||
|
void updatePeersAvatar(const QString& peer_id);
|
||||||
|
void updateAvatar();
|
||||||
|
void loadmystatusmessage();
|
||||||
|
void loadOwnStatus();
|
||||||
|
void checkAndSetIdle(int idleTime);
|
||||||
|
|
||||||
/** Called when this dialog is to be displayed */
|
LogoBar & getLogoBar() const;
|
||||||
void show();
|
|
||||||
void updateMessengerDisplay() ;
|
|
||||||
void updatePeersAvatar(const QString& peer_id);
|
|
||||||
void updateAvatar();
|
|
||||||
void loadmystatusmessage();
|
|
||||||
void loadOwnStatus();
|
|
||||||
void checkAndSetIdle(int idleTime);
|
|
||||||
|
|
||||||
LogoBar & getLogoBar() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent (QCloseEvent * event);
|
/** Default Constructor */
|
||||||
/** Default Constructor */
|
MessengerWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||||
MessengerWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
|
/** Default Destructor */
|
||||||
|
~MessengerWindow();
|
||||||
|
|
||||||
|
void closeEvent (QCloseEvent * event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
/** Create the context popup menu and it's submenus */
|
||||||
|
void messengertreeWidgetCostumPopupMenu( QPoint point );
|
||||||
|
|
||||||
/** Create the context popup menu and it's submenus */
|
/** Add a new friend */
|
||||||
void messengertreeWidgetCostumPopupMenu( QPoint point );
|
void addFriend();
|
||||||
|
/** Export friend */
|
||||||
|
void exportfriend();
|
||||||
|
/** Remove friend */
|
||||||
|
void removefriend();
|
||||||
|
/** start a chat with a friend **/
|
||||||
|
void chatfriend(QTreeWidgetItem *pPeer);
|
||||||
|
void chatfriendproxy();
|
||||||
|
/** start Messages Composer **/
|
||||||
|
void sendMessage();
|
||||||
|
/** start to connect to a friend **/
|
||||||
|
void connectfriend();
|
||||||
|
/** show peers details for each friend **/
|
||||||
|
void configurefriend();
|
||||||
|
|
||||||
/** Add a new friend */
|
/** Open Shared Manager **/
|
||||||
void addFriend();
|
void openShareManager();
|
||||||
/** Export friend */
|
|
||||||
void exportfriend();
|
|
||||||
/** Remove friend */
|
|
||||||
void removefriend();
|
|
||||||
/** start a chat with a friend **/
|
|
||||||
void chatfriend();
|
|
||||||
/** start Messages Composer **/
|
|
||||||
void sendMessage();
|
|
||||||
/** start to connect to a friend **/
|
|
||||||
void connectfriend();
|
|
||||||
/** show peers details for each friend **/
|
|
||||||
void configurefriend();
|
|
||||||
|
|
||||||
/** Open Shared Manager **/
|
/** get own last stored Avatar**/
|
||||||
void openShareManager();
|
void getAvatar();
|
||||||
|
|
||||||
/** get own last stored Avatar**/
|
void changeAvatarClicked();
|
||||||
void getAvatar();
|
|
||||||
|
|
||||||
void changeAvatarClicked();
|
void savestatusmessage();
|
||||||
|
|
||||||
void savestatusmessage();
|
void on_actionSort_Peers_Descending_Order_activated();
|
||||||
|
void on_actionSort_Peers_Ascending_Order_activated();
|
||||||
|
void on_actionRoot_is_decorated_activated();
|
||||||
|
|
||||||
|
void displayMenu();
|
||||||
|
|
||||||
|
void filterRegExpChanged();
|
||||||
void on_actionSort_Peers_Descending_Order_activated();
|
void clearFilter();
|
||||||
void on_actionSort_Peers_Ascending_Order_activated();
|
|
||||||
void on_actionRoot_is_decorated_activated();
|
|
||||||
void on_actionRoot_isnot_decorated_activated();
|
|
||||||
|
|
||||||
void displayMenu();
|
|
||||||
|
|
||||||
void filterRegExpChanged();
|
|
||||||
void clearFilter();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void friendsUpdated() ;
|
void friendsUpdated() ;
|
||||||
void startChat(QTreeWidgetItem* );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static MessengerWindow *mv;
|
||||||
|
|
||||||
static MessengerWindow *mv;
|
void processSettings(bool bLoad);
|
||||||
/* Worker Functions */
|
|
||||||
/* (1) Update Display */
|
|
||||||
|
|
||||||
/* (2) Utility Fns */
|
/* Worker Functions */
|
||||||
QTreeWidgetItem *getCurrentPeer();
|
/* (1) Update Display */
|
||||||
void savestatus();
|
|
||||||
void insertPeers();
|
|
||||||
// idle function
|
|
||||||
void setIdle(bool Idle);
|
|
||||||
bool isIdle;
|
|
||||||
const unsigned long maxTimeBeforeIdle;
|
|
||||||
|
|
||||||
void FilterItems();
|
/* (2) Utility Fns */
|
||||||
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern);
|
QTreeWidgetItem *getCurrentPeer();
|
||||||
|
void savestatus();
|
||||||
|
void insertPeers();
|
||||||
|
// idle function
|
||||||
|
void setIdle(bool Idle);
|
||||||
|
bool isIdle;
|
||||||
|
const unsigned long maxTimeBeforeIdle;
|
||||||
|
|
||||||
std::map<std::string, PopupChatDialog *> chatDialogs;
|
void FilterItems();
|
||||||
|
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern);
|
||||||
|
|
||||||
class QLabel *iconLabel, *textLabel;
|
class QLabel *iconLabel, *textLabel;
|
||||||
class QWidget *widget;
|
class QWidget *widget;
|
||||||
class QWidgetAction *widgetAction;
|
class QWidgetAction *widgetAction;
|
||||||
class QSpacerItem *spacerItem;
|
class QSpacerItem *spacerItem;
|
||||||
|
|
||||||
/** Defines the actions for the context menu */
|
/** Defines the actions for the context menu */
|
||||||
QAction* chatAct;
|
QAction* chatAct;
|
||||||
QAction* sendMessageAct;
|
QAction* sendMessageAct;
|
||||||
QAction* connectfriendAct;
|
QAction* connectfriendAct;
|
||||||
QAction* configurefriendAct;
|
QAction* configurefriendAct;
|
||||||
QAction* exportfriendAct;
|
QAction* exportfriendAct;
|
||||||
QAction* removefriendAct;
|
QAction* removefriendAct;
|
||||||
|
|
||||||
QTreeView *messengertreeWidget;
|
QTreeView *messengertreeWidget;
|
||||||
|
|
||||||
LogoBar * _rsLogoBarmessenger;
|
LogoBar * _rsLogoBarmessenger;
|
||||||
|
|
||||||
QFont itemFont;
|
QFont itemFont;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::MessengerWindow ui;
|
Ui::MessengerWindow ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -441,6 +441,9 @@ border: 1px solid #CCCCCC;
|
|||||||
<property name="indentation">
|
<property name="indentation">
|
||||||
<number>22</number>
|
<number>22</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sortingEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="columnCount">
|
<property name="columnCount">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@ -489,6 +492,9 @@ border: 1px solid #CCCCCC;
|
|||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionRoot_is_decorated">
|
<action name="actionRoot_is_decorated">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Set root is Decorated</string>
|
<string>Set root is Decorated</string>
|
||||||
</property>
|
</property>
|
||||||
@ -496,11 +502,6 @@ border: 1px solid #CCCCCC;
|
|||||||
<string>Set Root Decorated</string>
|
<string>Set Root Decorated</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionRoot_isnot_decorated">
|
|
||||||
<property name="text">
|
|
||||||
<string>Set Root is not Decorated</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionHide_Offline_Friends">
|
<action name="actionHide_Offline_Friends">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -509,6 +510,14 @@ border: 1px solid #CCCCCC;
|
|||||||
<string>Hide Offline Friends</string>
|
<string>Hide Offline Friends</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionSort_by_State">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Sort by State</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="images.qrc"/>
|
<include location="images.qrc"/>
|
||||||
|
@ -77,24 +77,15 @@
|
|||||||
#define COLUMN_INFO 2
|
#define COLUMN_INFO 2
|
||||||
#define COLUMN_ID 3
|
#define COLUMN_ID 3
|
||||||
|
|
||||||
// states for sorting (equal values are possible)
|
|
||||||
// used in BuildSortString - state + name
|
|
||||||
#define PEER_STATE_ONLINE 1
|
|
||||||
#define PEER_STATE_AWAY 2
|
|
||||||
#define PEER_STATE_BUSY 3
|
|
||||||
#define PEER_STATE_AVAILABLE 4
|
|
||||||
#define PEER_STATE_INACTIVE 5
|
|
||||||
#define PEER_STATE_OFFLINE 6
|
|
||||||
|
|
||||||
/******
|
/******
|
||||||
* #define PEERS_DEBUG 1
|
* #define PEERS_DEBUG 1
|
||||||
*****/
|
*****/
|
||||||
|
|
||||||
// quick and dirty for sorting, better use QTreeView and QSortFilterProxyModel
|
// quick and dirty for sorting, better use QTreeView and QSortFilterProxyModel
|
||||||
class MyTreeWidgetItem : public QTreeWidgetItem
|
class MyPeerTreeWidgetItem : public QTreeWidgetItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyTreeWidgetItem(QTreeWidget *pWidget, int type) : QTreeWidgetItem(type)
|
MyPeerTreeWidgetItem(QTreeWidget *pWidget, int type) : QTreeWidgetItem(type)
|
||||||
{
|
{
|
||||||
m_pWidget = pWidget; // can't access the member "view"
|
m_pWidget = pWidget; // can't access the member "view"
|
||||||
}
|
}
|
||||||
@ -142,7 +133,6 @@ PeersDialog::PeersDialog(QWidget *parent)
|
|||||||
|
|
||||||
connect( ui.peertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( peertreeWidgetCostumPopupMenu( QPoint ) ) );
|
connect( ui.peertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( peertreeWidgetCostumPopupMenu( QPoint ) ) );
|
||||||
connect( ui.peertreeWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(chatfriend(QTreeWidgetItem *)));
|
connect( ui.peertreeWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(chatfriend(QTreeWidgetItem *)));
|
||||||
connect( this , SIGNAL( startChat( QTreeWidgetItem *) ), this, SLOT(chatfriend(QTreeWidgetItem *)));
|
|
||||||
|
|
||||||
connect( ui.avatartoolButton, SIGNAL(clicked()), SLOT(getAvatar()));
|
connect( ui.avatartoolButton, SIGNAL(clicked()), SLOT(getAvatar()));
|
||||||
connect( ui.mypersonalstatuslabel, SIGNAL(clicked()), SLOT(statusmessage()));
|
connect( ui.mypersonalstatuslabel, SIGNAL(clicked()), SLOT(statusmessage()));
|
||||||
@ -263,12 +253,6 @@ PeersDialog::~PeersDialog ()
|
|||||||
// save settings
|
// save settings
|
||||||
processSettings(false);
|
processSettings(false);
|
||||||
|
|
||||||
std::map<std::string, PopupChatDialog *>::iterator it;
|
|
||||||
for (it = chatDialogs.begin(); it != chatDialogs.end(); it++) {
|
|
||||||
if (it->second) {
|
|
||||||
delete (it->second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete smWidget;
|
delete smWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,11 +421,6 @@ void PeersDialog::updateDisplay()
|
|||||||
insertPeers() ;
|
insertPeers() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString BuildSortString(QTreeWidgetItem *pItem, int nState)
|
|
||||||
{
|
|
||||||
return QString ("%1").arg(nState) + " " + pItem->text(COLUMN_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get the list of peers from the RsIface. */
|
/* get the list of peers from the RsIface. */
|
||||||
void PeersDialog::insertPeers()
|
void PeersDialog::insertPeers()
|
||||||
{
|
{
|
||||||
@ -520,7 +499,7 @@ void PeersDialog::insertPeers()
|
|||||||
|
|
||||||
bool bNew = false;
|
bool bNew = false;
|
||||||
if (gpg_item == NULL) {
|
if (gpg_item == NULL) {
|
||||||
gpg_item = new MyTreeWidgetItem(peertreeWidget, 0); //set type to 0 for custom popup menu
|
gpg_item = new MyPeerTreeWidgetItem(peertreeWidget, 0); //set type to 0 for custom popup menu
|
||||||
gpg_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
gpg_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||||
bNew = true;
|
bNew = true;
|
||||||
}
|
}
|
||||||
@ -577,7 +556,7 @@ void PeersDialog::insertPeers()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newChild) {
|
if (newChild) {
|
||||||
sslItem = new MyTreeWidgetItem(peertreeWidget, 1); //set type to 1 for custom popup menu
|
sslItem = new MyPeerTreeWidgetItem(peertreeWidget, 1); //set type to 1 for custom popup menu
|
||||||
}
|
}
|
||||||
|
|
||||||
/* not displayed, used to find back the item */
|
/* not displayed, used to find back the item */
|
||||||
@ -652,7 +631,7 @@ void PeersDialog::insertPeers()
|
|||||||
gpg_item->setHidden(false);
|
gpg_item->setHidden(false);
|
||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_ONLINE)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_ONLINE)));
|
||||||
gpg_item -> setText(COLUMN_STATE, tr("Online"));
|
gpg_item -> setText(COLUMN_STATE, tr("Online"));
|
||||||
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildSortString(gpg_item, PEER_STATE_ONLINE));
|
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), PEER_STATE_ONLINE));
|
||||||
|
|
||||||
std::list<StatusInfo>::iterator it;
|
std::list<StatusInfo>::iterator it;
|
||||||
for(it = statusInfo.begin(); it != statusInfo.end() ; it++) {
|
for(it = statusInfo.begin(); it != statusInfo.end() ; it++) {
|
||||||
@ -676,7 +655,7 @@ void PeersDialog::insertPeers()
|
|||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_INACTIVE)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_INACTIVE)));
|
||||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
|
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
|
||||||
gpg_item -> setText(COLUMN_STATE, tr("Idle"));
|
gpg_item -> setText(COLUMN_STATE, tr("Idle"));
|
||||||
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildSortString(gpg_item, PEER_STATE_INACTIVE));
|
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), PEER_STATE_INACTIVE));
|
||||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||||
gpg_item -> setTextColor(i,(Qt::gray));
|
gpg_item -> setTextColor(i,(Qt::gray));
|
||||||
gpg_item -> setFont(i,font);
|
gpg_item -> setFont(i,font);
|
||||||
@ -687,7 +666,7 @@ void PeersDialog::insertPeers()
|
|||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_ONLINE)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_ONLINE)));
|
||||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online"));
|
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online"));
|
||||||
gpg_item -> setText(COLUMN_STATE, tr("Online"));
|
gpg_item -> setText(COLUMN_STATE, tr("Online"));
|
||||||
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildSortString(gpg_item, PEER_STATE_ONLINE));
|
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), PEER_STATE_ONLINE));
|
||||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||||
gpg_item -> setTextColor(i,(Qt::darkBlue));
|
gpg_item -> setTextColor(i,(Qt::darkBlue));
|
||||||
gpg_item -> setFont(i,font);
|
gpg_item -> setFont(i,font);
|
||||||
@ -698,7 +677,7 @@ void PeersDialog::insertPeers()
|
|||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_AWAY)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_AWAY)));
|
||||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Away"));
|
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Away"));
|
||||||
gpg_item -> setText(COLUMN_STATE, tr("Away"));
|
gpg_item -> setText(COLUMN_STATE, tr("Away"));
|
||||||
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildSortString(gpg_item, PEER_STATE_AWAY));
|
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), PEER_STATE_AWAY));
|
||||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||||
gpg_item -> setTextColor(i,(Qt::gray));
|
gpg_item -> setTextColor(i,(Qt::gray));
|
||||||
gpg_item -> setFont(i,font);
|
gpg_item -> setFont(i,font);
|
||||||
@ -709,7 +688,7 @@ void PeersDialog::insertPeers()
|
|||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_BUSY)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_BUSY)));
|
||||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Busy"));
|
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Busy"));
|
||||||
gpg_item -> setText(COLUMN_STATE, tr("Busy"));
|
gpg_item -> setText(COLUMN_STATE, tr("Busy"));
|
||||||
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildSortString(gpg_item, PEER_STATE_BUSY));
|
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), PEER_STATE_BUSY));
|
||||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||||
gpg_item -> setTextColor(i,(Qt::gray));
|
gpg_item -> setTextColor(i,(Qt::gray));
|
||||||
gpg_item -> setFont(i,font);
|
gpg_item -> setFont(i,font);
|
||||||
@ -722,7 +701,7 @@ void PeersDialog::insertPeers()
|
|||||||
gpg_item->setHidden(bHideUnconnected);
|
gpg_item->setHidden(bHideUnconnected);
|
||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_AVAIBLE)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_AVAIBLE)));
|
||||||
gpg_item -> setText(COLUMN_STATE, tr("Available"));
|
gpg_item -> setText(COLUMN_STATE, tr("Available"));
|
||||||
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildSortString(gpg_item, PEER_STATE_AVAILABLE));
|
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), PEER_STATE_AVAILABLE));
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setBold(true);
|
font.setBold(true);
|
||||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||||
@ -733,7 +712,7 @@ void PeersDialog::insertPeers()
|
|||||||
gpg_item->setHidden(bHideUnconnected);
|
gpg_item->setHidden(bHideUnconnected);
|
||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_OFFLINE)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_OFFLINE)));
|
||||||
gpg_item -> setText(COLUMN_STATE, tr("Offline"));
|
gpg_item -> setText(COLUMN_STATE, tr("Offline"));
|
||||||
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildSortString(gpg_item, PEER_STATE_OFFLINE));
|
gpg_item -> setData(COLUMN_STATE, Qt::UserRole, BuildStateSortString(true, gpg_item->text(COLUMN_NAME), PEER_STATE_OFFLINE));
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setBold(false);
|
font.setBold(false);
|
||||||
for(i = 0; i < COLUMN_COUNT; i++) {
|
for(i = 0; i < COLUMN_COUNT; i++) {
|
||||||
@ -790,96 +769,32 @@ void PeersDialog::exportfriend()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeersDialog::chatfriendproxy(){
|
void PeersDialog::chatfriendproxy()
|
||||||
|
|
||||||
QTreeWidgetItem* i = getCurrentPeer();
|
|
||||||
|
|
||||||
if(!i)
|
|
||||||
return;
|
|
||||||
|
|
||||||
emit startChat(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeersDialog::chatfriend(QTreeWidgetItem* currPeer)
|
|
||||||
{
|
{
|
||||||
// QTreeWidgetItem *currPeer = getCurrentPeer();
|
chatfriend(getCurrentPeer());
|
||||||
|
|
||||||
if (!currPeer){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//std::string name = (i -> text(2)).toStdString();
|
|
||||||
std::string id = (currPeer -> text(COLUMN_ID)).toStdString();
|
|
||||||
|
|
||||||
bool oneLocationConnected = false;
|
|
||||||
|
|
||||||
RsPeerDetails detail;
|
|
||||||
if (!rsPeers->getPeerDetails(id, detail)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (detail.isOnlyGPGdetail) {
|
|
||||||
//let's get the ssl child details, and open all the chat boxes
|
|
||||||
std::list<std::string> sslIds;
|
|
||||||
rsPeers->getSSLChildListOfGPGId(detail.gpg_id, sslIds);
|
|
||||||
for (std::list<std::string>::iterator it = sslIds.begin(); it != sslIds.end(); it++) {
|
|
||||||
RsPeerDetails sslDetails;
|
|
||||||
if (rsPeers->getPeerDetails(*it, sslDetails)) {
|
|
||||||
if (sslDetails.state & RS_PEER_STATE_CONNECTED) {
|
|
||||||
oneLocationConnected = true;
|
|
||||||
getPrivateChat(*it, sslDetails.name + " - " + sslDetails.location, RS_CHAT_REOPEN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (detail.state & RS_PEER_STATE_CONNECTED) {
|
|
||||||
oneLocationConnected = true;
|
|
||||||
getPrivateChat(id, detail.name + " - " + detail.location, RS_CHAT_REOPEN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!oneLocationConnected) {
|
|
||||||
/* info dialog */
|
|
||||||
if ((QMessageBox::question(this, tr("Friend Not Online"),tr("Your Friend is offline \nDo you want to send them a Message instead"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes)
|
|
||||||
{
|
|
||||||
msgfriend();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PeersDialog::chatfriend(QTreeWidgetItem *pPeer)
|
||||||
|
{
|
||||||
|
if (pPeer == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string id = (pPeer->text(COLUMN_ID)).toStdString();
|
||||||
|
PopupChatDialog::chatFriend(id);
|
||||||
|
}
|
||||||
|
|
||||||
void PeersDialog::msgfriend()
|
void PeersDialog::msgfriend()
|
||||||
{
|
{
|
||||||
#ifdef PEERS_DEBUG
|
QTreeWidgetItem *peer = getCurrentPeer();
|
||||||
std::cerr << "SharedFilesDialog::msgfriend()" << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QTreeWidgetItem *i = getCurrentPeer();
|
if (!peer)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!i)
|
std::string id = (peer->text(COLUMN_ID)).toStdString();
|
||||||
return;
|
MessageComposer::msgFriend(id);
|
||||||
|
|
||||||
std::string id = (i -> text(COLUMN_ID)).toStdString();
|
|
||||||
|
|
||||||
rsicontrol -> ClearInMsg();
|
|
||||||
rsicontrol -> SetInMsg(id, true);
|
|
||||||
std::list<std::string> sslIds;
|
|
||||||
rsPeers->getSSLChildListOfGPGId(id, sslIds);
|
|
||||||
for (std::list<std::string>::iterator it = sslIds.begin(); it != sslIds.end(); it++) {
|
|
||||||
//put all sslChilds in message list
|
|
||||||
rsicontrol -> SetInMsg(*it, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* create a message */
|
|
||||||
MessageComposer *nMsgDialog = new MessageComposer();
|
|
||||||
|
|
||||||
nMsgDialog->newMsg();
|
|
||||||
nMsgDialog->show();
|
|
||||||
|
|
||||||
/* window will destroy itself! */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QTreeWidgetItem *PeersDialog::getCurrentPeer()
|
QTreeWidgetItem *PeersDialog::getCurrentPeer()
|
||||||
{
|
{
|
||||||
/* get the current, and extract the Id */
|
/* get the current, and extract the Id */
|
||||||
@ -1027,7 +942,7 @@ void PeersDialog::updatePeersAvatar(const QString& peer_id)
|
|||||||
std::cerr << "PeersDialog: Got notified of new avatar for peer " << peer_id.toStdString() << std::endl ;
|
std::cerr << "PeersDialog: Got notified of new avatar for peer " << peer_id.toStdString() << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PopupChatDialog *pcd = getPrivateChat(peer_id.toStdString(),rsPeers->getPeerName(peer_id.toStdString()), 0);
|
PopupChatDialog *pcd = PopupChatDialog::getPrivateChat(peer_id.toStdString(),rsPeers->getPeerName(peer_id.toStdString()), 0);
|
||||||
pcd->updatePeerAvatar(peer_id.toStdString());
|
pcd->updatePeerAvatar(peer_id.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1035,7 +950,7 @@ void PeersDialog::updatePeerStatusString(const QString& peer_id,const QString& s
|
|||||||
{
|
{
|
||||||
if(is_private_chat)
|
if(is_private_chat)
|
||||||
{
|
{
|
||||||
PopupChatDialog *pcd = getPrivateChat(peer_id.toStdString(),rsPeers->getPeerName(peer_id.toStdString()), 0);
|
PopupChatDialog *pcd = PopupChatDialog::getPrivateChat(peer_id.toStdString(),rsPeers->getPeerName(peer_id.toStdString()), 0);
|
||||||
pcd->updateStatusString(status_string);
|
pcd->updateStatusString(status_string);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1085,7 +1000,7 @@ void PeersDialog::insertChat()
|
|||||||
/* are they private? */
|
/* are they private? */
|
||||||
if (it->chatflags & RS_CHAT_PRIVATE)
|
if (it->chatflags & RS_CHAT_PRIVATE)
|
||||||
{
|
{
|
||||||
PopupChatDialog *pcd = getPrivateChat(it->rsid, it->name, chatflags);
|
PopupChatDialog *pcd = PopupChatDialog::getPrivateChat(it->rsid, it->name, chatflags);
|
||||||
pcd->addChatMsg(&(*it));
|
pcd->addChatMsg(&(*it));
|
||||||
playsound();
|
playsound();
|
||||||
QApplication::alert(pcd);
|
QApplication::alert(pcd);
|
||||||
@ -1289,90 +1204,6 @@ void PeersDialog::toggleSendItem( QTreeWidgetItem *item, int col )
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
PopupChatDialog *
|
|
||||||
PeersDialog::getPrivateChat(std::string id, std::string name, uint chatflags)
|
|
||||||
{
|
|
||||||
/* see if it exists already */
|
|
||||||
PopupChatDialog *popupchatdialog = NULL;
|
|
||||||
bool show = false;
|
|
||||||
|
|
||||||
if (chatflags & RS_CHAT_REOPEN)
|
|
||||||
{
|
|
||||||
show = true;
|
|
||||||
#ifdef PEERS_DEBUG
|
|
||||||
std::cerr << "reopen flag so: enable SHOW popupchatdialog()" << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::map<std::string, PopupChatDialog *>::iterator it;
|
|
||||||
if (chatDialogs.end() != (it = chatDialogs.find(id)))
|
|
||||||
{
|
|
||||||
/* exists already */
|
|
||||||
popupchatdialog = it->second;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
popupchatdialog = new PopupChatDialog(id, name);
|
|
||||||
chatDialogs[id] = popupchatdialog;
|
|
||||||
|
|
||||||
if (chatflags & RS_CHAT_OPEN_NEW)
|
|
||||||
{
|
|
||||||
#ifdef PEERS_DEBUG
|
|
||||||
std::cerr << "new chat so: enable SHOW popupchatdialog()" << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
show = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (show)
|
|
||||||
{
|
|
||||||
#ifdef PEERS_DEBUG
|
|
||||||
std::cerr << "SHOWING popupchatdialog()" << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
popupchatdialog->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now only do these if the window is visible */
|
|
||||||
if (popupchatdialog->isVisible())
|
|
||||||
{
|
|
||||||
if (chatflags & RS_CHAT_FOCUS)
|
|
||||||
{
|
|
||||||
#ifdef PEERS_DEBUG
|
|
||||||
std::cerr << "focus chat flag so: GETFOCUS popupchatdialog()" << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
popupchatdialog->getfocus();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#ifdef PEERS_DEBUG
|
|
||||||
std::cerr << "no focus chat flag so: FLASH popupchatdialog()" << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
popupchatdialog->flash();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#ifdef PEERS_DEBUG
|
|
||||||
std::cerr << "not visible ... so leave popupchatdialog()" << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return popupchatdialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
|
|
||||||
void PeersDialog::clearOldChats()
|
|
||||||
{
|
|
||||||
/* nothing yet */
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeersDialog::setColor()
|
void PeersDialog::setColor()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1623,8 +1454,7 @@ void PeersDialog::updateAvatar()
|
|||||||
pix.loadFromData(data,size,"PNG") ;
|
pix.loadFromData(data,size,"PNG") ;
|
||||||
ui.avatartoolButton->setIcon(pix); // writes image into ba in PNG format
|
ui.avatartoolButton->setIcon(pix); // writes image into ba in PNG format
|
||||||
|
|
||||||
for(std::map<std::string, PopupChatDialog *>::const_iterator it(chatDialogs.begin());it!=chatDialogs.end();++it)
|
PopupChatDialog::updateAllAvatars();
|
||||||
it->second->updateAvatar() ;
|
|
||||||
|
|
||||||
delete[] data ;
|
delete[] data ;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,17 @@
|
|||||||
|
|
||||||
#include "im_history/IMHistoryKeeper.h"
|
#include "im_history/IMHistoryKeeper.h"
|
||||||
|
|
||||||
|
// states for sorting (equal values are possible)
|
||||||
|
// used in BuildSortString - state + name
|
||||||
|
#define PEER_STATE_ONLINE 1
|
||||||
|
#define PEER_STATE_AWAY 2
|
||||||
|
#define PEER_STATE_BUSY 3
|
||||||
|
#define PEER_STATE_AVAILABLE 4
|
||||||
|
#define PEER_STATE_INACTIVE 5
|
||||||
|
#define PEER_STATE_OFFLINE 6
|
||||||
|
|
||||||
|
#define BuildStateSortString(bEnabled,sName,nState) bEnabled ? (QString ("%1").arg(nState) + " " + sName) : sName
|
||||||
|
|
||||||
class QFont;
|
class QFont;
|
||||||
class QAction;
|
class QAction;
|
||||||
class QTextEdit;
|
class QTextEdit;
|
||||||
@ -49,9 +60,6 @@ public:
|
|||||||
/** Default Destructor */
|
/** Default Destructor */
|
||||||
~PeersDialog ();
|
~PeersDialog ();
|
||||||
|
|
||||||
PopupChatDialog *getPrivateChat(std::string id, std::string name, uint chatflags);
|
|
||||||
void clearOldChats();
|
|
||||||
|
|
||||||
void loadEmoticonsgroupchat();
|
void loadEmoticonsgroupchat();
|
||||||
// void setChatDialog(ChatDialog *cd);
|
// void setChatDialog(ChatDialog *cd);
|
||||||
|
|
||||||
@ -146,7 +154,6 @@ private slots:
|
|||||||
signals:
|
signals:
|
||||||
void friendsUpdated() ;
|
void friendsUpdated() ;
|
||||||
void notifyGroupChat(const QString&,const QString&) ;
|
void notifyGroupChat(const QString&,const QString&) ;
|
||||||
void startChat(QTreeWidgetItem* );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void processSettings(bool bLoad);
|
void processSettings(bool bLoad);
|
||||||
@ -192,8 +199,6 @@ private:
|
|||||||
QHash<QString, QString> smileys;
|
QHash<QString, QString> smileys;
|
||||||
QWidget *smWidget;
|
QWidget *smWidget;
|
||||||
|
|
||||||
std::map<std::string, PopupChatDialog *> chatDialogs;
|
|
||||||
|
|
||||||
QFont mCurrentFont; /* how the text will come out */
|
QFont mCurrentFont; /* how the text will come out */
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
|
@ -29,10 +29,12 @@
|
|||||||
#include "rsiface/rspeers.h"
|
#include "rsiface/rspeers.h"
|
||||||
#include "rsiface/rsmsgs.h"
|
#include "rsiface/rsmsgs.h"
|
||||||
#include "rsiface/rsfiles.h"
|
#include "rsiface/rsfiles.h"
|
||||||
|
#include "rsiface/rsnotify.h"
|
||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
|
|
||||||
|
|
||||||
#include "gui/feeds/AttachFileItem.h"
|
#include "gui/feeds/AttachFileItem.h"
|
||||||
|
#include "gui/msgs/MessageComposer.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#define appDir QApplication::applicationDirPath()
|
#define appDir QApplication::applicationDirPath()
|
||||||
@ -46,6 +48,8 @@
|
|||||||
* #define CHAT_DEBUG 1
|
* #define CHAT_DEBUG 1
|
||||||
*****/
|
*****/
|
||||||
|
|
||||||
|
static std::map<std::string, PopupChatDialog *> chatDialogs;
|
||||||
|
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||||
QWidget *parent, Qt::WFlags flags)
|
QWidget *parent, Qt::WFlags flags)
|
||||||
@ -140,6 +144,145 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
|||||||
updatePeerAvatar(id) ;
|
updatePeerAvatar(id) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*static*/ PopupChatDialog *PopupChatDialog::getPrivateChat(std::string id, std::string name, uint chatflags)
|
||||||
|
{
|
||||||
|
/* see if it exists already */
|
||||||
|
PopupChatDialog *popupchatdialog = NULL;
|
||||||
|
bool show = false;
|
||||||
|
|
||||||
|
if (chatflags & RS_CHAT_REOPEN)
|
||||||
|
{
|
||||||
|
show = true;
|
||||||
|
#ifdef PEERS_DEBUG
|
||||||
|
std::cerr << "reopen flag so: enable SHOW popupchatdialog()" << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, PopupChatDialog *>::iterator it;
|
||||||
|
if (chatDialogs.end() != (it = chatDialogs.find(id)))
|
||||||
|
{
|
||||||
|
/* exists already */
|
||||||
|
popupchatdialog = it->second;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
popupchatdialog = new PopupChatDialog(id, name);
|
||||||
|
chatDialogs[id] = popupchatdialog;
|
||||||
|
|
||||||
|
if (chatflags & RS_CHAT_OPEN_NEW)
|
||||||
|
{
|
||||||
|
#ifdef PEERS_DEBUG
|
||||||
|
std::cerr << "new chat so: enable SHOW popupchatdialog()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
show = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
#ifdef PEERS_DEBUG
|
||||||
|
std::cerr << "SHOWING popupchatdialog()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (popupchatdialog->isVisible() == false) {
|
||||||
|
if (chatflags & RS_CHAT_FOCUS) {
|
||||||
|
popupchatdialog->show();
|
||||||
|
} else {
|
||||||
|
popupchatdialog->showMinimized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* now only do these if the window is visible */
|
||||||
|
if (popupchatdialog->isVisible())
|
||||||
|
{
|
||||||
|
if (chatflags & RS_CHAT_FOCUS)
|
||||||
|
{
|
||||||
|
#ifdef PEERS_DEBUG
|
||||||
|
std::cerr << "focus chat flag so: GETFOCUS popupchatdialog()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
popupchatdialog->getfocus();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef PEERS_DEBUG
|
||||||
|
std::cerr << "no focus chat flag so: FLASH popupchatdialog()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
popupchatdialog->flash();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef PEERS_DEBUG
|
||||||
|
std::cerr << "not visible ... so leave popupchatdialog()" << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return popupchatdialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ void PopupChatDialog::cleanupChat()
|
||||||
|
{
|
||||||
|
std::map<std::string, PopupChatDialog *>::iterator it;
|
||||||
|
for (it = chatDialogs.begin(); it != chatDialogs.end(); it++) {
|
||||||
|
if (it->second) {
|
||||||
|
delete (it->second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
chatDialogs.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupChatDialog::chatFriend(std::string id)
|
||||||
|
{
|
||||||
|
if (id.empty()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool oneLocationConnected = false;
|
||||||
|
|
||||||
|
RsPeerDetails detail;
|
||||||
|
if (!rsPeers->getPeerDetails(id, detail)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (detail.isOnlyGPGdetail) {
|
||||||
|
//let's get the ssl child details, and open all the chat boxes
|
||||||
|
std::list<std::string> sslIds;
|
||||||
|
rsPeers->getSSLChildListOfGPGId(detail.gpg_id, sslIds);
|
||||||
|
for (std::list<std::string>::iterator it = sslIds.begin(); it != sslIds.end(); it++) {
|
||||||
|
RsPeerDetails sslDetails;
|
||||||
|
if (rsPeers->getPeerDetails(*it, sslDetails)) {
|
||||||
|
if (sslDetails.state & RS_PEER_STATE_CONNECTED) {
|
||||||
|
oneLocationConnected = true;
|
||||||
|
getPrivateChat(*it, sslDetails.name + " - " + sslDetails.location, RS_CHAT_REOPEN | RS_CHAT_FOCUS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (detail.state & RS_PEER_STATE_CONNECTED) {
|
||||||
|
oneLocationConnected = true;
|
||||||
|
getPrivateChat(id, detail.name + " - " + detail.location, RS_CHAT_REOPEN | RS_CHAT_FOCUS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!oneLocationConnected) {
|
||||||
|
/* info dialog */
|
||||||
|
if ((QMessageBox::question(NULL, tr("Friend Not Online"),tr("Your Friend is offline \nDo you want to send them a Message instead"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes) {
|
||||||
|
MessageComposer::msgFriend(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ void PopupChatDialog::updateAllAvatars()
|
||||||
|
{
|
||||||
|
for(std::map<std::string, PopupChatDialog *>::const_iterator it(chatDialogs.begin());it!=chatDialogs.end();++it)
|
||||||
|
it->second->updateAvatar() ;
|
||||||
|
}
|
||||||
|
|
||||||
void PopupChatDialog::pasteLink()
|
void PopupChatDialog::pasteLink()
|
||||||
{
|
{
|
||||||
std::cerr << "In paste link" << std::endl ;
|
std::cerr << "In paste link" << std::endl ;
|
||||||
|
@ -44,11 +44,10 @@ class PopupChatDialog : public QMainWindow
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Default constructor */
|
static PopupChatDialog *getPrivateChat(std::string id, std::string name, uint chatflags);
|
||||||
PopupChatDialog(std::string id, std::string name,
|
static void cleanupChat();
|
||||||
QWidget *parent = 0, Qt::WFlags flags = 0);
|
static void chatFriend(std::string id);
|
||||||
/** Default destructor */
|
static void updateAllAvatars();
|
||||||
~PopupChatDialog();
|
|
||||||
|
|
||||||
void updateChat();
|
void updateChat();
|
||||||
void updatePeerAvatar(const std::string&);
|
void updatePeerAvatar(const std::string&);
|
||||||
@ -85,6 +84,12 @@ public slots:
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/** Default constructor */
|
||||||
|
PopupChatDialog(std::string id, std::string name,
|
||||||
|
QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||||
|
/** Default destructor */
|
||||||
|
~PopupChatDialog();
|
||||||
|
|
||||||
void closeEvent (QCloseEvent * event);
|
void closeEvent (QCloseEvent * event);
|
||||||
virtual void dragEnterEvent(QDragEnterEvent *event);
|
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||||
virtual void dropEvent(QDropEvent *event);
|
virtual void dropEvent(QDropEvent *event);
|
||||||
|
@ -66,8 +66,10 @@ signals:
|
|||||||
* <b>topic</b>. */
|
* <b>topic</b>. */
|
||||||
void helpRequested(const QString &topic);
|
void helpRequested(const QString &topic);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
QString _name; /**< Name associated with this window. */
|
QString _name; /**< Name associated with this window. */
|
||||||
|
|
||||||
|
private:
|
||||||
bool m_bSaveStateOnClose; // is set to true in restoreWindowState
|
bool m_bSaveStateOnClose; // is set to true in restoreWindowState
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -197,6 +197,30 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*static*/ void MessageComposer::msgFriend(std::string id)
|
||||||
|
{
|
||||||
|
#ifdef PEERS_DEBUG
|
||||||
|
std::cerr << "MessageComposer::msgfriend()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
rsicontrol -> ClearInMsg();
|
||||||
|
rsicontrol -> SetInMsg(id, true);
|
||||||
|
std::list<std::string> sslIds;
|
||||||
|
rsPeers->getSSLChildListOfGPGId(id, sslIds);
|
||||||
|
for (std::list<std::string>::iterator it = sslIds.begin(); it != sslIds.end(); it++) {
|
||||||
|
//put all sslChilds in message list
|
||||||
|
rsicontrol -> SetInMsg(*it, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create a message */
|
||||||
|
MessageComposer *pMsgDialog = new MessageComposer();
|
||||||
|
|
||||||
|
pMsgDialog->newMsg();
|
||||||
|
pMsgDialog->show();
|
||||||
|
|
||||||
|
/* window will destroy itself! */
|
||||||
|
}
|
||||||
|
|
||||||
void MessageComposer::closeEvent (QCloseEvent * event)
|
void MessageComposer::closeEvent (QCloseEvent * event)
|
||||||
{
|
{
|
||||||
bool bClose = true;
|
bool bClose = true;
|
||||||
|
@ -46,6 +46,8 @@ public:
|
|||||||
|
|
||||||
MessageComposer(QWidget *parent = 0, Qt::WFlags flags = 0);
|
MessageComposer(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||||
|
|
||||||
|
static void msgFriend(std::string id);
|
||||||
|
|
||||||
void newMsg(std::string msgId = "");
|
void newMsg(std::string msgId = "");
|
||||||
|
|
||||||
/* worker fns */
|
/* worker fns */
|
||||||
|
@ -175,7 +175,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
w->installGroupChatNotifier();
|
w->installGroupChatNotifier();
|
||||||
|
|
||||||
QObject::connect(w->messengerWindow,SIGNAL(startChat(QTreeWidgetItem* )),w->peersDialog,SLOT(chatfriend(QTreeWidgetItem* ))) ;
|
|
||||||
QObject::connect(w->idle, SIGNAL(secondsIdle(int)), w->messengerWindow, SLOT(checkAndSetIdle(int)));
|
QObject::connect(w->idle, SIGNAL(secondsIdle(int)), w->messengerWindow, SLOT(checkAndSetIdle(int)));
|
||||||
|
|
||||||
/* only show window, if not startMinimized */
|
/* only show window, if not startMinimized */
|
||||||
@ -194,6 +193,9 @@ int main(int argc, char *argv[])
|
|||||||
int ti = rshare.exec();
|
int ti = rshare.exec();
|
||||||
delete w ;
|
delete w ;
|
||||||
|
|
||||||
|
/* cleanup */
|
||||||
|
PopupChatDialog::cleanupChat();
|
||||||
|
|
||||||
rsicontrol->rsGlobalShutDown();
|
rsicontrol->rsGlobalShutDown();
|
||||||
|
|
||||||
Settings->sync();
|
Settings->sync();
|
||||||
|
Loading…
Reference in New Issue
Block a user