mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 16:15:23 -04:00
- fixed a few bugs in PopupDistantChatDialog (Possible deadlock, wrong window for private chat)
- added method to properly close distant chat conversation (Still needs some work) - improved chat link creation window + clipboard copy git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6426 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3f752b9eae
commit
42db43e590
10 changed files with 111 additions and 25 deletions
|
@ -20,6 +20,8 @@
|
|||
****************************************************************/
|
||||
|
||||
#include <QTimer>
|
||||
#include <QCloseEvent>
|
||||
#include "RsAutoUpdatePage.h"
|
||||
#include "PopupDistantChatDialog.h"
|
||||
|
||||
#define IMAGE_RED_LED ":/images/redled.png"
|
||||
|
@ -27,24 +29,25 @@
|
|||
#define IMAGE_GRN_LED ":/images/greenled.png"
|
||||
#define IMAGE_GRY_LED ":/images/grayled.png"
|
||||
|
||||
PopupDistantChatDialog::~PopupDistantChatDialog()
|
||||
{
|
||||
delete _tunnel_check_timer ;
|
||||
PopupDistantChatDialog::~PopupDistantChatDialog()
|
||||
{
|
||||
_update_timer->stop() ;
|
||||
delete _update_timer ;
|
||||
}
|
||||
|
||||
PopupDistantChatDialog::PopupDistantChatDialog(QWidget *parent, Qt::WFlags flags)
|
||||
: PopupChatDialog(parent,flags)
|
||||
{
|
||||
_tunnel_check_timer = new QTimer;
|
||||
_tunnel_check_timer->setInterval(1000) ;
|
||||
|
||||
QObject::connect(_tunnel_check_timer,SIGNAL(timeout()),this,SLOT(checkTunnel())) ;
|
||||
|
||||
_tunnel_check_timer->start() ;
|
||||
_status_label = new QLabel ;
|
||||
_update_timer = new QTimer ;
|
||||
|
||||
_update_timer->setInterval(1000) ;
|
||||
QObject::connect(_update_timer,SIGNAL(timeout()),this,SLOT(updateDisplay())) ;
|
||||
|
||||
_update_timer->start() ;
|
||||
|
||||
addChatBarWidget(_status_label) ;
|
||||
checkTunnel() ;
|
||||
updateDisplay() ;
|
||||
}
|
||||
|
||||
void PopupDistantChatDialog::init(const std::string& hash,const QString & title)
|
||||
|
@ -53,8 +56,11 @@ void PopupDistantChatDialog::init(const std::string& hash,const QString & title)
|
|||
PopupChatDialog::init(hash,title) ;
|
||||
}
|
||||
|
||||
void PopupDistantChatDialog::checkTunnel()
|
||||
void PopupDistantChatDialog::updateDisplay()
|
||||
{
|
||||
if(RsAutoUpdatePage::eventsLocked()) // we need to do that by end, because it's not possible to derive from both PopupChatDialog and RsAutoUpdatePage
|
||||
return ; // which both derive from QObject. Signals-slot connexions won't work anymore.
|
||||
|
||||
if(!isVisible())
|
||||
return ;
|
||||
|
||||
|
@ -70,23 +76,33 @@ void PopupDistantChatDialog::checkTunnel()
|
|||
{
|
||||
case RS_DISTANT_CHAT_STATUS_UNKNOWN: std::cerr << "Unknown hash. Error!" << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_GRY_LED)) ;
|
||||
_status_label->setToolTip(tr("Hash error")) ;
|
||||
_status_label->setToolTip(QObject::tr("Hash error")) ;
|
||||
break ;
|
||||
case RS_DISTANT_CHAT_STATUS_TUNNEL_DN: std::cerr << "Tunnel asked. Waiting for reponse. " << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_RED_LED)) ;
|
||||
_status_label->setToolTip(tr("Tunnel is broken")) ;
|
||||
_status_label->setToolTip(QObject::tr("Tunnel is broken")) ;
|
||||
break ;
|
||||
case RS_DISTANT_CHAT_STATUS_TUNNEL_OK: std::cerr << "Tunnel is ok. " << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_YEL_LED)) ;
|
||||
_status_label->setToolTip(tr("Tunnel established")) ;
|
||||
_status_label->setToolTip(QObject::tr("Tunnel established")) ;
|
||||
break ;
|
||||
case RS_DISTANT_CHAT_STATUS_CAN_TALK: std::cerr << "Tunnel is ok and works. You can talk!" << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_GRN_LED)) ;
|
||||
_status_label->setToolTip(tr("Tunnel is working")) ;
|
||||
_status_label->setToolTip(QObject::tr("Tunnel is working")) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
void PopupDistantChatDialog::closeEvent(QCloseEvent *e)
|
||||
{
|
||||
std::cerr << "Closing window => closing distant chat for hash " << _hash << std::endl;
|
||||
rsMsgs->closeDistantChatConnexion(_hash) ;
|
||||
|
||||
e->accept() ;
|
||||
|
||||
PopupChatDialog::closeEvent(e) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -95,4 +111,3 @@ void PopupDistantChatDialog::checkTunnel()
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "PopupChatDialog.h"
|
||||
|
||||
class QTimer ;
|
||||
class QCloseEvent ;
|
||||
|
||||
class PopupDistantChatDialog: public PopupChatDialog
|
||||
{
|
||||
|
@ -32,10 +33,7 @@ class PopupDistantChatDialog: public PopupChatDialog
|
|||
|
||||
friend class ChatDialog;
|
||||
|
||||
public slots:
|
||||
void checkTunnel() ;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
/** Default constructor */
|
||||
PopupDistantChatDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
/** Default destructor */
|
||||
|
@ -43,8 +41,13 @@ protected:
|
|||
|
||||
virtual void init(const std::string& _hash, const QString &title);
|
||||
virtual void updateStatus(int /*status*/) {}
|
||||
virtual void closeEvent(QCloseEvent *e) ;
|
||||
|
||||
QTimer *_tunnel_check_timer ;
|
||||
protected slots:
|
||||
void updateDisplay() ; // overloads RsAutoUpdatePage
|
||||
|
||||
private:
|
||||
QTimer *_update_timer ;
|
||||
std::string _hash ;
|
||||
std::string _virtual_peer_id ;
|
||||
QLabel *_status_label ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue