diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index 5c35a2b8c..84aa4f12e 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -31,6 +31,7 @@ #include "rshare.h" #include "MessengerWindow.h" +#include "RsAutoUpdatePage.h" #include "chat/PopupChatDialog.h" #include "msgs/MessageComposer.h" @@ -41,7 +42,7 @@ #include "settings/rsharesettings.h" #include "gui/connect/ConnectFriendWizard.h" - +#include "PeersDialog.h" #include "ShareManager.h" #include @@ -64,11 +65,47 @@ #define IMAGE_BUSY ":/images/im-user-busy.png" #define IMAGE_INACTIVE ":/images/im-user-inactive.png" +#define COLUMN_COUNT 4 +#define COLUMN_NAME 0 +#define COLUMN_STATE 1 +#define COLUMN_INFO 2 +#define COLUMN_ID 3 + /****** * #define MSG_DEBUG 1 *****/ MessengerWindow* MessengerWindow::mv = 0; +// quick and dirty for sorting, better use QTreeView and QSortFilterProxyModel +class MyMessengerTreeWidgetItem : public QTreeWidgetItem +{ +public: + MyMessengerTreeWidgetItem(QTreeWidget *pWidget, int type) : QTreeWidgetItem(type) + { + m_pWidget = pWidget; // can't access the member "view" + } + + bool operator<(const QTreeWidgetItem &other) const + { + int column = m_pWidget ? m_pWidget->sortColumn() : 0; + + switch (column) { + case COLUMN_NAME: + { + const QVariant v1 = data(column, Qt::UserRole); + const QVariant v2 = other.data(column, Qt::UserRole); + return (v1.toString().compare (v2.toString(), Qt::CaseInsensitive) < 0); + } + } + + // let the standard do the sort + return QTreeWidgetItem::operator<(other); + } + +private: + QTreeWidget *m_pWidget; // the member "view" is private +}; + MessengerWindow* MessengerWindow::getInstance() { if(mv == 0) @@ -90,71 +127,121 @@ void MessengerWindow::releaseInstance() MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags) : RWindow("MessengerWindow", parent, flags), maxTimeBeforeIdle(30) { - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); - - connect( ui.messengertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messengertreeWidgetCostumPopupMenu( QPoint ) ) ); - connect( ui.messengertreeWidget, SIGNAL(itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(chatfriend())); + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); - connect( ui.avatarButton, SIGNAL(clicked()), SLOT(getAvatar())); - connect( ui.shareButton, SIGNAL(clicked()), SLOT(openShareManager())); - connect( ui.addIMAccountButton, SIGNAL(clicked( bool ) ), this , SLOT( addFriend() ) ); - connect( ui.actionHide_Offline_Friends, SIGNAL(triggered()), this, SLOT(insertPeers())); - connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter())); - - connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage())); - connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged())); + connect( ui.messengertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messengertreeWidgetCostumPopupMenu( QPoint ) ) ); + connect( ui.messengertreeWidget, SIGNAL(itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(chatfriend(QTreeWidgetItem *))); - QTimer *timer = new QTimer(this); - timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateMessengerDisplay())); - timer->start(1000); /* one second */ + connect( ui.avatarButton, SIGNAL(clicked()), SLOT(getAvatar())); + connect( ui.shareButton, SIGNAL(clicked()), SLOT(openShareManager())); + connect( ui.addIMAccountButton, SIGNAL(clicked( bool ) ), this , SLOT( addFriend() ) ); + connect( ui.actionHide_Offline_Friends, SIGNAL(triggered()), this, SLOT(insertPeers())); + connect( ui.actionSort_by_State, SIGNAL(triggered()), this, SLOT(insertPeers())); + connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter())); + + connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage())); + connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged())); + + QTimer *timer = new QTimer(this); + timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateMessengerDisplay())); + timer->start(1000); /* one second */ - /* to hide the header */ - ui.messengertreeWidget->header()->hide(); - - /* Set header resize modes and initial section sizes */ - ui.messengertreeWidget->setColumnCount(4); - ui.messengertreeWidget->setColumnHidden ( 3, true); - ui.messengertreeWidget->setColumnHidden ( 2, true); - //ui.messengertreeWidget->sortItems( 0, Qt::AscendingOrder ); + /* to hide the header */ + ui.messengertreeWidget->header()->hide(); - QHeaderView * _header = ui.messengertreeWidget->header () ; - _header->setResizeMode (0, QHeaderView::Stretch); - _header->setResizeMode (1, QHeaderView::Custom); - _header->setStretchLastSection(false); + /* Set header resize modes and initial section sizes */ + ui.messengertreeWidget->setColumnCount(COLUMN_COUNT); + ui.messengertreeWidget->setColumnHidden ( COLUMN_ID, true); + ui.messengertreeWidget->setColumnHidden ( COLUMN_INFO, true); + ui.messengertreeWidget->sortItems( COLUMN_NAME, Qt::AscendingOrder ); + + QHeaderView * _header = ui.messengertreeWidget->header () ; + _header->setResizeMode (COLUMN_NAME, QHeaderView::Stretch); + _header->setResizeMode (COLUMN_STATE, QHeaderView::Custom); + _header->setStretchLastSection(false); - _header->resizeSection ( 0, 200 ); - _header->resizeSection ( 1, 42 ); - - //LogoBar - _rsLogoBarmessenger = NULL; - _rsLogoBarmessenger = new LogoBar(ui.logoframe); - Widget::createLayout(ui.logoframe)->addWidget(_rsLogoBarmessenger); - - ui.statuscomboBox->setMinimumWidth(20); - ui.messagelineEdit->setMinimumWidth(20); + _header->resizeSection ( COLUMN_NAME, 200 ); + _header->resizeSection ( COLUMN_STATE, 42 ); - itemFont = QFont("ARIAL", 10); - itemFont.setBold(true); + //LogoBar + _rsLogoBarmessenger = NULL; + _rsLogoBarmessenger = new LogoBar(ui.logoframe); + Widget::createLayout(ui.logoframe)->addWidget(_rsLogoBarmessenger); - isIdle = false; - loadOwnStatus(); // hack; placed in constructor to preempt sendstatus, so status loaded from file - insertPeers(); - updateAvatar(); - loadmystatusmessage(); - - ui.clearButton->hide(); + ui.statuscomboBox->setMinimumWidth(20); + ui.messagelineEdit->setMinimumWidth(20); - displayMenu(); - updateMessengerDisplay(); - - /* Hide platform specific features */ + itemFont = QFont("ARIAL", 10); + itemFont.setBold(true); + + displayMenu(); + + // load settings + processSettings(true); + + isIdle = false; + loadOwnStatus(); // hack; placed in constructor to preempt sendstatus, so status loaded from file + insertPeers(); + updateAvatar(); + loadmystatusmessage(); + + ui.clearButton->hide(); + + updateMessengerDisplay(); + + /* Hide platform specific features */ #ifdef Q_WS_WIN #endif } +MessengerWindow::~MessengerWindow () +{ + // save settings + processSettings(false); +} + +void MessengerWindow::processSettings(bool bLoad) +{ + QHeaderView *header = ui.messengertreeWidget->header (); + + Settings->beginGroup(_name); + + if (bLoad) { + // load settings + + // state of messenger tree + header->restoreState(Settings->value("MessengerTree").toByteArray()); + + // state of actionHide_Offline_Friends + ui.actionHide_Offline_Friends->setChecked(Settings->value("hideOfflineFriends", false).toBool()); + + // state of actionSort_by_State + ui.actionSort_by_State->setChecked(Settings->value("sortByState", false).toBool()); + + // state of actionRoot_is_decorated + ui.actionRoot_is_decorated->setChecked(Settings->value("rootIsDecorated", true).toBool()); + on_actionRoot_is_decorated_activated(); + } else { + // save settings + + // state of messenger tree + Settings->setValue("MessengerTree", header->saveState()); + + // state of actionSort_by_State + Settings->setValue("sortByState", ui.actionSort_by_State->isChecked()); + + // state of actionHide_Offline_Friends + Settings->setValue("hideOfflineFriends", ui.actionHide_Offline_Friends->isChecked()); + + // state of actionRoot_is_decorated + Settings->setValue("rootIsDecorated", ui.actionRoot_is_decorated->isChecked()); + } + + Settings->endGroup(); +} void MessengerWindow::messengertreeWidgetCostumPopupMenu( QPoint point ) { @@ -174,7 +261,7 @@ void MessengerWindow::messengertreeWidgetCostumPopupMenu( QPoint point ) connect( collapseAll , SIGNAL( triggered() ), ui.messengertreeWidget, SLOT(collapseAll()) ); chatAct = new QAction(QIcon(IMAGE_CHAT), tr( "Chat" ), this ); - connect( chatAct , SIGNAL( triggered() ), this, SLOT( chatfriend() ) ); + connect( chatAct , SIGNAL( triggered() ), this, SLOT( chatfriendproxy() ) ); sendMessageAct = new QAction(QIcon(IMAGE_MSG), tr( "Message Friend" ), this ); connect( sendMessageAct , SIGNAL( triggered() ), this, SLOT( sendMessage() ) ); @@ -266,208 +353,205 @@ void MessengerWindow::updateMessengerDisplay() /* get the list of peers from the RsIface. */ void MessengerWindow::insertPeers() { - std::list gpgFriends; - std::list::iterator it; + std::list gpgFriends; + std::list::iterator it; + std::list statusInfo; + rsStatus->getStatus(statusInfo); - std::list statusInfo; - rsStatus->getStatus(statusInfo); - - // if(isIdle) + // if(isIdle) // QMessageBox::StandardButton sb = QMessageBox::warning ( NULL, tr("Idle"), - // tr("You are Idle"), QMessageBox::Ok); + // tr("You are Idle"), QMessageBox::Ok); - if (!rsPeers) { - /* not ready yet! */ - std::cerr << "PeersDialog::insertPeers() not ready yet : rsPeers unintialized." << std::endl; - return; + if (!rsPeers) { + /* not ready yet! */ + std::cerr << "PeersDialog::insertPeers() not ready yet : rsPeers unintialized." << std::endl; + return; + } + + rsPeers->getGPGAcceptedList(gpgFriends); + + //add own gpg id, if we have more than on location (ssl client) + std::list ownSslContacts; + rsPeers->getSSLChildListOfGPGId(rsPeers->getGPGOwnId(), ownSslContacts); + if (ownSslContacts.size() > 0) { + gpgFriends.push_back(rsPeers->getGPGOwnId()); + } + + /* get a link to the table */ + QTreeWidget *peertreeWidget = ui.messengertreeWidget; + + bool bSortState = ui.actionSort_by_State->isChecked(); + + //remove items that are not fiends anymore + int index = 0; + while (index < peertreeWidget->topLevelItemCount()) { + std::string gpg_widget_id = (peertreeWidget->topLevelItem(index))->text(COLUMN_ID).toStdString(); + std::list::iterator gpgfriendIt; + bool found = false; + for (gpgfriendIt = gpgFriends.begin(); gpgfriendIt != gpgFriends.end(); gpgfriendIt++) { + if (gpg_widget_id == *gpgfriendIt) { + found = true; + break; + } + } + if (!found) { + delete (peertreeWidget->takeTopLevelItem(index)); + } else { + index++; + } + } + + //add the gpg friends + for(it = gpgFriends.begin(); it != gpgFriends.end(); it++) { + // if (*it == rsPeers->getGPGOwnId()) { + // continue; + // } + + /* make a widget per friend */ + QTreeWidgetItem *gpg_item = NULL; + QList list = peertreeWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, COLUMN_ID); + if (list.size() == 1) { + gpg_item = list.front(); } - rsPeers->getGPGAcceptedList(gpgFriends); - - //add own gpg id, if we have more than on location (ssl client) - std::list ownSslContacts; - rsPeers->getSSLChildListOfGPGId(rsPeers->getGPGOwnId(), ownSslContacts); - if (ownSslContacts.size() > 0) { - gpgFriends.push_back(rsPeers->getGPGOwnId()); + RsPeerDetails detail; + if ((!rsPeers->getPeerDetails(*it, detail) || !detail.accept_connection) + && detail.gpg_id != rsPeers->getGPGOwnId()) { + //don't accept anymore connection, remove from the view + delete (peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(gpg_item))); + continue; } - /* get a link to the table */ - QTreeWidget *peertreeWidget = ui.messengertreeWidget; + if (gpg_item == NULL) { + gpg_item = new MyMessengerTreeWidgetItem(peertreeWidget, 0); //set type to 0 for custom popup menu + gpg_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); + } - //remove items that are not fiends anymore - int index = 0; - while (index < peertreeWidget->topLevelItemCount()) { - std::string gpg_widget_id = (peertreeWidget->topLevelItem(index))->text(3).toStdString(); - std::list::iterator gpgfriendIt; - bool found = false; - for (gpgfriendIt = gpgFriends.begin(); gpgfriendIt != gpgFriends.end(); gpgfriendIt++) { - if (gpg_widget_id == *gpgfriendIt) { - found = true; + gpg_item -> setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter ); + + gpg_item -> setSizeHint(COLUMN_NAME, QSize( 27,27 ) ); + + /* not displayed, used to find back the item */ + gpg_item -> setText(COLUMN_ID, QString::fromStdString(detail.id)); + + //remove items that are not friends anymore + int childIndex = 0; + while (childIndex < gpg_item->childCount()) { + std::string ssl_id = (gpg_item->child(childIndex))->text(COLUMN_ID).toStdString(); + if (!rsPeers->isFriend(ssl_id)) { + delete (gpg_item->takeChild(childIndex)); + } else { + childIndex++; + } + } + + //update the childs (ssl certs) + bool gpg_connected = false; + bool gpg_online = false; + std::list sslContacts; + rsPeers->getSSLChildListOfGPGId(detail.gpg_id, sslContacts); + for(std::list::iterator sslIt = sslContacts.begin(); sslIt != sslContacts.end(); sslIt++) { + QTreeWidgetItem *sslItem = NULL; + + //find the corresponding sslItem child item of the gpg item + bool newChild = true; + for (int childIndex = 0; childIndex < gpg_item->childCount(); childIndex++) { + if (gpg_item->child(childIndex)->text(COLUMN_ID).toStdString() == *sslIt) { + sslItem = gpg_item->child(childIndex); + newChild = false; break; } } - if (!found) { - delete (peertreeWidget->takeTopLevelItem(index)); - } else { - index++; - } - } - - //add the gpg friends - for(it = gpgFriends.begin(); it != gpgFriends.end(); it++) { -// if (*it == rsPeers->getGPGOwnId()) { -// continue; -// } - - /* make a widget per friend */ - QTreeWidgetItem *gpg_item; - QList list = peertreeWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, 3); - if (list.size() == 1) { - gpg_item = list.front(); - } else { - gpg_item = new QTreeWidgetItem(0); //set type to 0 for custom popup menu - gpg_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); - } - - RsPeerDetails detail; - if ((!rsPeers->getPeerDetails(*it, detail) || !detail.accept_connection) - && detail.gpg_id != rsPeers->getGPGOwnId()) { - //don't accept anymore connection, remove from the view - delete (peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(gpg_item))); + RsPeerDetails sslDetail; + if (!rsPeers->getPeerDetails(*sslIt, sslDetail) || !rsPeers->isFriend(*sslIt)) { + std::cerr << "Removing widget from the view : id : " << *sslIt << std::endl; + if (sslItem) { + //child has disappeared, remove it from the gpg_item + gpg_item->removeChild(sslItem); + } continue; } - //use to mark item as updated - gpg_item->setData(0, Qt::UserRole, true); - - gpg_item -> setTextAlignment(0, Qt::AlignLeft | Qt::AlignVCenter ); - - gpg_item -> setSizeHint(0, QSize( 27,27 ) ); + if (sslItem == NULL) { + sslItem = new MyMessengerTreeWidgetItem(peertreeWidget, 1); //set type to 1 for custom popup menu + } /* not displayed, used to find back the item */ - gpg_item -> setText(3, QString::fromStdString(detail.id)); + sslItem -> setText(COLUMN_ID, QString::fromStdString(sslDetail.id)); - //remove items that are not friends anymore - int childIndex = 0; - while (childIndex < gpg_item->childCount()) { - std::string ssl_id = (gpg_item->child(childIndex))->text(3).toStdString(); - if (!rsPeers->isFriend(ssl_id)) { - delete (gpg_item->takeChild(childIndex)); + QString sCustomString = QString::fromStdString(rsMsgs->getCustomStateString(sslDetail.id)); + if (sCustomString != "") { + sslItem -> setText( COLUMN_NAME, tr("location : ") + QString::fromStdString(sslDetail.location) + " " + QString::fromStdString(sslDetail.autoconnect) ); + sslItem -> setToolTip( COLUMN_NAME, tr("location : ") + QString::fromStdString(sslDetail.location) + tr(" - ") + sCustomString); + gpg_item -> setText(COLUMN_NAME, QString::fromStdString(detail.name) + tr("\n") + sCustomString); + } else { + sslItem -> setText( COLUMN_NAME, tr("location : ") + QString::fromStdString(sslDetail.location) + " " + QString::fromStdString(sslDetail.autoconnect)); + sslItem -> setToolTip( COLUMN_NAME, tr("location : ") + QString::fromStdString(sslDetail.location)); + gpg_item -> setText(COLUMN_NAME, QString::fromStdString(detail.name) + tr("\n") + QString::fromStdString(sslDetail.location)); + } + + /* not displayed, used to find back the item */ + //sslItem -> setText(1, QString::fromStdString(sslDetail.autoconnect)); + + int i; + if (sslDetail.state & RS_PEER_STATE_CONNECTED) { + sslItem->setHidden(false); + gpg_connected = true; + + /* change color and icon */ + sslItem -> setIcon(COLUMN_NAME,(QIcon(":/images/connect_established.png"))); + QFont font; + font.setBold(true); + for(i = 0; i < COLUMN_COUNT; i++) { + sslItem -> setTextColor(i,(Qt::darkBlue)); + sslItem -> setFont(i,font); + } + } else if (sslDetail.state & RS_PEER_STATE_ONLINE) { + sslItem->setHidden(ui.actionHide_Offline_Friends->isChecked()); + gpg_online = true; + + QFont font; + font.setBold(true); + for(i = 0; i < COLUMN_COUNT; i++) { + sslItem -> setTextColor(i,(Qt::black)); + sslItem -> setFont(i,font); + } + } else { + sslItem->setHidden(ui.actionHide_Offline_Friends->isChecked()); + if (sslDetail.autoconnect !="Offline") { + sslItem -> setIcon(COLUMN_NAME, (QIcon(":/images/connect_creating.png"))); } else { - childIndex++; + sslItem -> setIcon(COLUMN_NAME, (QIcon(":/images/connect_no.png"))); + } + + QFont font; + font.setBold(false); + for(i = 0; i < COLUMN_COUNT; i++) { + sslItem -> setTextColor(i,(Qt::black)); + sslItem -> setFont(i,font); } } - //update the childs (ssl certs) - bool gpg_connected = false; - bool gpg_online = false; - std::list sslContacts; - rsPeers->getSSLChildListOfGPGId(detail.gpg_id, sslContacts); - for(std::list::iterator sslIt = sslContacts.begin(); sslIt != sslContacts.end(); sslIt++) { - QTreeWidgetItem *sslItem = NULL; - - //find the corresponding sslItem child item of the gpg item - bool newChild = true; - for (int childIndex = 0; childIndex < gpg_item->childCount(); childIndex++) { - if (gpg_item->child(childIndex)->text(3).toStdString() == *sslIt) { - sslItem = gpg_item->child(childIndex); - newChild = false; - break; - } - } - - RsPeerDetails sslDetail; - if (!rsPeers->getPeerDetails(*sslIt, sslDetail) || !rsPeers->isFriend(*sslIt)) { - std::cerr << "Removing widget from the view : id : " << *sslIt << std::endl; - if (sslItem) { - //child has disappeared, remove it from the gpg_item - gpg_item->removeChild(sslItem); - } - continue; - } - - if (sslItem == NULL) { - sslItem = new QTreeWidgetItem(1); //set type to 1 for custom popup menu - } - - /* not displayed, used to find back the item */ - sslItem -> setText(3, QString::fromStdString(sslDetail.id)); - - if (rsMsgs->getCustomStateString(sslDetail.id) != "") { - sslItem -> setText( 0, tr("location : ") + QString::fromStdString(sslDetail.location) + " " + QString::fromStdString(sslDetail.autoconnect) ); - sslItem -> setToolTip( 0, tr("location : ") + QString::fromStdString(sslDetail.location) + tr(" - ") + QString::fromStdString(rsMsgs->getCustomStateString(sslDetail.id))); - gpg_item -> setText(0, QString::fromStdString(detail.name) + tr("\n") + QString::fromStdString(rsMsgs->getCustomStateString(sslDetail.id))); - - } else { - sslItem -> setText( 0, tr("location : ") + QString::fromStdString(sslDetail.location) + " " + QString::fromStdString(sslDetail.autoconnect)); - sslItem -> setToolTip( 0, tr("location : ") + QString::fromStdString(sslDetail.location)); - gpg_item -> setText(0, QString::fromStdString(detail.name) + tr("\n") + QString::fromStdString(sslDetail.location)); - } - - - /* not displayed, used to find back the item */ - //sslItem -> setText(1, QString::fromStdString(sslDetail.autoconnect)); - - int i; - if (sslDetail.state & RS_PEER_STATE_CONNECTED) { - sslItem->setHidden(false); - gpg_connected = true; - - /* change color and icon */ - sslItem -> setIcon(0,(QIcon(":/images/connect_established.png"))); - QFont font; - font.setBold(true); - for(i = 0; i < 3; i++) { - sslItem -> setTextColor(i,(Qt::darkBlue)); - sslItem -> setFont(i,font); - } - } else if (sslDetail.state & RS_PEER_STATE_ONLINE) { - sslItem->setHidden(ui.actionHide_Offline_Friends->isChecked()); - gpg_online = true; - - QFont font; - font.setBold(true); - for(i = 0; i < 3; i++) { - sslItem -> setTextColor(i,(Qt::black)); - sslItem -> setFont(i,font); - } - } else { - sslItem->setHidden(ui.actionHide_Offline_Friends->isChecked()); - if (sslDetail.autoconnect !="Offline") { - sslItem -> setIcon(0, (QIcon(":/images/connect_creating.png"))); - } else { - sslItem -> setIcon(0, (QIcon(":/images/connect_no.png"))); - } - - QFont font; - font.setBold(false); - for(i = 0; i < 3; i++) { - sslItem -> setTextColor(i,(Qt::black)); - sslItem -> setFont(i,font); - } - } - - #ifdef PEERS_DEBUG - std::cerr << "PeersDialog::insertPeers() inserting sslItem." << std::endl; - #endif - /* add sl child to the list. If item is already in the list, it won't be duplicated thanks to Qt */ - gpg_item->addChild(sslItem); - if (newChild) { - gpg_item->setExpanded(true); - } +#ifdef PEERS_DEBUG + std::cerr << "PeersDialog::insertPeers() inserting sslItem." << std::endl; +#endif + /* add sl child to the list. If item is already in the list, it won't be duplicated thanks to Qt */ + gpg_item->addChild(sslItem); + if (newChild) { + gpg_item->setExpanded(true); } + } + + int i = 0; + if (gpg_connected) { + gpg_item->setHidden(false); + //gpg_item -> setText(COLUMN_STATE, tr("Online")); // set to online regardless on update + + std::list::iterator it = statusInfo.begin(); - int i = 0; - if (gpg_connected) { - gpg_item->setHidden(false); - //gpg_item -> setText(1, tr("Online")); // set to online regardless on update - - std::list::iterator it = statusInfo.begin(); - - - for(; it != statusInfo.end() ; it++){ + for(; it != statusInfo.end() ; it++){ std::list::iterator cont_it = sslContacts.begin(); @@ -475,107 +559,106 @@ void MessengerWindow::insertPeers() for(; cont_it != sslContacts.end(); cont_it++){ - if((it->id == *cont_it) && (rsPeers->isOnline(*cont_it))){ + if((it->id == *cont_it) && (rsPeers->isOnline(*cont_it))) { - std::string status; - rsStatus->getStatusString(it->status, status); - gpg_item -> setText(1, QString::fromStdString(status)); - - QFont font; - font.setBold(true); + std::string status; + rsStatus->getStatusString(it->status, status); + gpg_item -> setText(COLUMN_STATE, QString::fromStdString(status)); - unsigned char *data = NULL; - int size = 0 ; - rsMsgs->getAvatarData(it->id ,data,size); + QFont font; + font.setBold(true); - if(size != 0){ + unsigned char *data = NULL; + int size = 0 ; + rsMsgs->getAvatarData(it->id ,data,size); - QPixmap avatar ; - avatar.loadFromData(data,size,"PNG") ; - QIcon avatar_icon(avatar); - QSize av_icon_size(100, 100); - gpg_item-> setIcon(1, avatar_icon); - delete[] data; + if(size != 0){ + QPixmap avatar ; + avatar.loadFromData(data,size,"PNG") ; + QIcon avatar_icon(avatar); + QSize av_icon_size(100, 100); + gpg_item-> setIcon(1, avatar_icon); + delete[] data; + + } else { + gpg_item -> setIcon(COLUMN_STATE,(QIcon(":/images/no_avatar_70.png"))); + } + if(it->status == RS_STATUS_INACTIVE) + { + gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_INACTIVE))); + gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle")); + gpg_item->setData(COLUMN_NAME, Qt::UserRole, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_INACTIVE)); + + for(i = 0; i < COLUMN_COUNT; i++) { + gpg_item -> setTextColor(i,(Qt::gray)); + gpg_item -> setFont(i,font); + } + } + else if(it->status == RS_STATUS_ONLINE) + { + gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_ONLINE))); + gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online")); + gpg_item->setData(COLUMN_NAME, Qt::UserRole, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_ONLINE)); + + for(i = 0; i < COLUMN_COUNT; i++) { + gpg_item -> setTextColor(i,(Qt::darkBlue)); + gpg_item -> setFont(i,font); + } + } + else if(it->status == RS_STATUS_AWAY) + { + gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_AWAY))); + gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Away")); + gpg_item->setData(COLUMN_NAME, Qt::UserRole, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_AWAY)); + + for(i = 0; i < COLUMN_COUNT; i++) { + gpg_item -> setTextColor(i,(Qt::gray)); + gpg_item -> setFont(i,font); + } + } + else if(it->status == RS_STATUS_BUSY) + { + gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_BUSY))); + gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Busy")); + gpg_item->setData(COLUMN_NAME, Qt::UserRole, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_BUSY)); + + for(i = 0; i < COLUMN_COUNT; i++) { + gpg_item -> setTextColor(i,(Qt::gray)); + gpg_item -> setFont(i,font); + } + } - }else - { - gpg_item -> setIcon(1,(QIcon(":/images/no_avatar_70.png"))); - } - if(it->status == RS_STATUS_INACTIVE) - { - gpg_item -> setIcon(0,(QIcon(IMAGE_INACTIVE))); - gpg_item -> setToolTip(0, tr("Peer Idle")); - - for(i = 0; i < 3; i++) { - gpg_item -> setTextColor(i,(Qt::gray)); - gpg_item -> setFont(i,font); - } - } - else - if(it->status == RS_STATUS_ONLINE) - { - gpg_item -> setIcon(0,(QIcon(IMAGE_ONLINE))); - gpg_item -> setToolTip(0, tr("Peer Online")); - - for(i = 0; i < 3; i++) { - gpg_item -> setTextColor(i,(Qt::darkBlue)); - gpg_item -> setFont(i,font); } - } - else - if(it->status == RS_STATUS_AWAY) - { - gpg_item -> setIcon(0,(QIcon(IMAGE_AWAY))); - gpg_item -> setToolTip(0, tr("Peer Away")); - - for(i = 0; i < 3; i++) { - gpg_item -> setTextColor(i,(Qt::gray)); - gpg_item -> setFont(i,font); - } - } - else - if(it->status == RS_STATUS_BUSY) - { - gpg_item -> setIcon(0,(QIcon(IMAGE_BUSY))); - gpg_item -> setToolTip(0, tr("Peer Busy")); - - for(i = 0; i < 3; i++) { - gpg_item -> setTextColor(i,(Qt::gray)); - gpg_item -> setFont(i,font); - } - } - - } - } - } - - - } else if (gpg_online) { - gpg_item->setHidden(ui.actionHide_Offline_Friends->isChecked()); - gpg_item -> setIcon(0,(QIcon(IMAGE_AVAIBLE))); - //gpg_item -> setText(1, tr("Available")); - QFont font; - font.setBold(true); - for(i = 0; i < 3; i++) { - gpg_item -> setTextColor(i,(Qt::black)); - gpg_item -> setFont(i,font); - } - } else { - gpg_item->setHidden(ui.actionHide_Offline_Friends->isChecked()); - gpg_item -> setIcon(0,(QIcon(IMAGE_OFFLINE))); - //gpg_item -> setText(1, tr("Offline")); - QFont font; - font.setBold(false); - for(i = 0; i < 3; i++) { - gpg_item -> setTextColor(i,(Qt::black)); - gpg_item -> setFont(i,font); } } - - /* add gpg item to the list. If item is already in the list, it won't be duplicated thanks to Qt */ - peertreeWidget->addTopLevelItem(gpg_item); + } else if (gpg_online) { + gpg_item->setHidden(ui.actionHide_Offline_Friends->isChecked()); + gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_AVAIBLE))); + gpg_item->setData(COLUMN_NAME, Qt::UserRole, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_ONLINE)); + //gpg_item -> setText(COLUMN_STATE, tr("Available")); + QFont font; + font.setBold(true); + for(i = 0; i < COLUMN_COUNT; i++) { + gpg_item -> setTextColor(i,(Qt::black)); + gpg_item -> setFont(i,font); + } + } else { + gpg_item->setHidden(ui.actionHide_Offline_Friends->isChecked()); + gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_OFFLINE))); + gpg_item->setData(COLUMN_NAME, Qt::UserRole, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_OFFLINE)); + //gpg_item -> setText(COLUMN_STATE, tr("Offline")); + QFont font; + font.setBold(false); + for(i = 0; i < COLUMN_COUNT; i++) { + gpg_item -> setTextColor(i,(Qt::black)); + gpg_item -> setFont(i,font); + } } - + + /* add gpg item to the list. If item is already in the list, it won't be duplicated thanks to Qt */ + peertreeWidget->addTopLevelItem(gpg_item); + } + if (ui.filterPatternLineEdit->text().isEmpty() == false) { FilterItems(); } @@ -584,8 +667,8 @@ void MessengerWindow::insertPeers() /* Utility Fns */ std::string getPeersRsCertId(QTreeWidgetItem *i) { - std::string id = (i -> text(3)).toStdString(); - return id; + std::string id = (i -> text(COLUMN_ID)).toStdString(); + return id; } /** Add a Friend ShortCut */ @@ -631,17 +714,20 @@ void MessengerWindow::exportfriend() } -void MessengerWindow::chatfriend() +void MessengerWindow::chatfriendproxy() { - QTreeWidgetItem *i = getCurrentPeer(); - - if (!i) - return; - - emit startChat(i); - + chatfriend(getCurrentPeer()); } +void MessengerWindow::chatfriend(QTreeWidgetItem *pPeer) +{ + if (pPeer == NULL) { + return; + } + + std::string id = (pPeer->text(COLUMN_ID)).toStdString(); + PopupChatDialog::chatFriend(id); +} QTreeWidgetItem *MessengerWindow::getCurrentPeer() { @@ -723,7 +809,7 @@ void MessengerWindow::connectfriend() if (rsPeers) { rsPeers->connectAttempt(getPeersRsCertId(c)); - c -> setIcon(0,(QIcon(IMAGE_CONNECT2))); + c -> setIcon(COLUMN_NAME,(QIcon(IMAGE_CONNECT2))); } } @@ -737,84 +823,12 @@ void MessengerWindow::updatePeersAvatar(const QString& peer_id) { std::cerr << "PeersDialog: Got notified of new avatar for peer " << peer_id.toStdString() << std::endl ; - 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()); } //============================================================================ -PopupChatDialog * -MessengerWindow::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; - std::cerr << "reopen flag so: enable SHOW popupchatdialog()"; - std::cerr << std::endl; - } - - - std::map::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) - { - std::cerr << "new chat so: enable SHOW popupchatdialog()"; - std::cerr << std::endl; - - show = true; - } - } - - if (show) - { - std::cerr << "SHOWING popupchatdialog()"; - std::cerr << std::endl; - - popupchatdialog->show(); - } - - /* now only do these if the window is visible */ - if (popupchatdialog->isVisible()) - { - if (chatflags & RS_CHAT_FOCUS) - { - std::cerr << "focus chat flag so: GETFOCUS popupchatdialog()"; - std::cerr << std::endl; - - popupchatdialog->getfocus(); - } - else - { - std::cerr << "no focus chat flag so: FLASH popupchatdialog()"; - std::cerr << std::endl; - - popupchatdialog->flash(); - } - } - else - { - std::cerr << "not visible ... so leave popupchatdialog()"; - std::cerr << std::endl; - } - - return popupchatdialog; -} - -//============================================================================ - /** Overloads the default show */ void MessengerWindow::show() @@ -846,35 +860,13 @@ void MessengerWindow::openShareManager() void MessengerWindow::sendMessage() { -#ifdef MESSENGERWINDOW_DEBUG - std::cerr << "SharedFilesDialog::sendMessage()" << std::endl; -#endif + QTreeWidgetItem *peer = getCurrentPeer(); - QTreeWidgetItem *i = getCurrentPeer(); + if (!peer) + return; - if (!i) - return; - - std::string status = (i -> text(1)).toStdString(); - std::string name = (i -> text(2)).toStdString(); - std::string id = (i -> text(3)).toStdString(); - - rsicontrol -> ClearInMsg(); - rsicontrol -> SetInMsg(id, true); - std::list sslIds; - rsPeers->getSSLChildListOfGPGId(id, sslIds); - for (std::list::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! */ + std::string id = (peer->text(COLUMN_ID)).toStdString(); + MessageComposer::msgFriend(id); } LogoBar & MessengerWindow::getLogoBar() const { @@ -946,38 +938,29 @@ void MessengerWindow::savestatusmessage() void MessengerWindow::on_actionSort_Peers_Descending_Order_activated() { - ui.messengertreeWidget->sortItems ( 0, Qt::DescendingOrder ); + ui.messengertreeWidget->sortItems ( COLUMN_NAME, Qt::DescendingOrder ); } void MessengerWindow::on_actionSort_Peers_Ascending_Order_activated() { - ui.messengertreeWidget->sortItems ( 0, Qt::AscendingOrder ); + ui.messengertreeWidget->sortItems ( COLUMN_NAME, Qt::AscendingOrder ); } void MessengerWindow::on_actionRoot_is_decorated_activated() { - ui.messengertreeWidget->setRootIsDecorated(true); -} - -void MessengerWindow::on_actionRoot_isnot_decorated_activated() -{ - ui.messengertreeWidget->setRootIsDecorated(false); + ui.messengertreeWidget->setRootIsDecorated(ui.actionRoot_is_decorated->isChecked()); } void MessengerWindow::displayMenu() { - QMenu *lookmenu = new QMenu(); - lookmenu->addAction(ui.actionSort_Peers_Descending_Order); - lookmenu->addAction(ui.actionSort_Peers_Ascending_Order); - lookmenu->addAction(ui.actionHide_Offline_Friends); - - QMenu *viewMenu = new QMenu( tr("View"), this ); - viewMenu->addAction(ui.actionRoot_is_decorated); - viewMenu->addAction(ui.actionRoot_isnot_decorated); - lookmenu->addMenu( viewMenu); - - ui.displaypushButton->setMenu(lookmenu); + QMenu *lookmenu = new QMenu(); + lookmenu->addAction(ui.actionSort_Peers_Descending_Order); + lookmenu->addAction(ui.actionSort_Peers_Ascending_Order); + lookmenu->addAction(ui.actionSort_by_State); + lookmenu->addAction(ui.actionHide_Offline_Friends); + lookmenu->addAction(ui.actionRoot_is_decorated); + ui.displaypushButton->setMenu(lookmenu); } /** Load own status Online,Away,Busy **/ diff --git a/retroshare-gui/src/gui/MessengerWindow.h b/retroshare-gui/src/gui/MessengerWindow.h index fe2ca003b..12a5aa9e8 100644 --- a/retroshare-gui/src/gui/MessengerWindow.h +++ b/retroshare-gui/src/gui/MessengerWindow.h @@ -21,139 +21,128 @@ #ifndef _MESSENGERWINDOW_H #define _MESSENGERWINDOW_H -#include -#include "mainpage.h" #include "ui_MessengerWindow.h" #include -#include "chat/PopupChatDialog.h" -#include "RsAutoUpdatePage.h" - class LogoBar; class PeersDialog; +class PopupChatDialog; 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: + /** 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 */ - void show(); - void updateMessengerDisplay() ; - void updatePeersAvatar(const QString& peer_id); - void updateAvatar(); - void loadmystatusmessage(); - void loadOwnStatus(); - void checkAndSetIdle(int idleTime); - - LogoBar & getLogoBar() const; + LogoBar & getLogoBar() const; protected: - void closeEvent (QCloseEvent * event); - /** Default Constructor */ - MessengerWindow(QWidget *parent = 0, Qt::WFlags flags = 0); + /** Default Constructor */ + MessengerWindow(QWidget *parent = 0, Qt::WFlags flags = 0); + /** Default Destructor */ + ~MessengerWindow(); + void closeEvent (QCloseEvent * event); private slots: + /** Create the context popup menu and it's submenus */ + void messengertreeWidgetCostumPopupMenu( QPoint point ); - /** Create the context popup menu and it's submenus */ - void messengertreeWidgetCostumPopupMenu( QPoint point ); - - /** Add a new friend */ - void addFriend(); - /** 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(); + /** Add a new friend */ + 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(); - /** Open Shared Manager **/ - void openShareManager(); - - /** get own last stored Avatar**/ - void getAvatar(); - - void changeAvatarClicked(); - - void savestatusmessage(); - - + /** Open Shared Manager **/ + void openShareManager(); - void on_actionSort_Peers_Descending_Order_activated(); - 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(); + /** get own last stored Avatar**/ + void getAvatar(); + + void changeAvatarClicked(); + + 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 clearFilter(); signals: - void friendsUpdated() ; - void startChat(QTreeWidgetItem* ); + void friendsUpdated() ; private: + static MessengerWindow *mv; - static MessengerWindow *mv; - /* Worker Functions */ - /* (1) Update Display */ + void processSettings(bool bLoad); - /* (2) Utility Fns */ - QTreeWidgetItem *getCurrentPeer(); - void savestatus(); - void insertPeers(); - // idle function - void setIdle(bool Idle); - bool isIdle; - const unsigned long maxTimeBeforeIdle; - - void FilterItems(); - bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern); + /* Worker Functions */ + /* (1) Update Display */ - std::map chatDialogs; + /* (2) Utility Fns */ + QTreeWidgetItem *getCurrentPeer(); + void savestatus(); + void insertPeers(); + // idle function + void setIdle(bool Idle); + bool isIdle; + const unsigned long maxTimeBeforeIdle; - class QLabel *iconLabel, *textLabel; - class QWidget *widget; - class QWidgetAction *widgetAction; - class QSpacerItem *spacerItem; + void FilterItems(); + bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern); - /** Defines the actions for the context menu */ - QAction* chatAct; - QAction* sendMessageAct; - QAction* connectfriendAct; - QAction* configurefriendAct; - QAction* exportfriendAct; - QAction* removefriendAct; + class QLabel *iconLabel, *textLabel; + class QWidget *widget; + class QWidgetAction *widgetAction; + class QSpacerItem *spacerItem; - QTreeView *messengertreeWidget; + /** Defines the actions for the context menu */ + QAction* chatAct; + QAction* sendMessageAct; + QAction* connectfriendAct; + QAction* configurefriendAct; + QAction* exportfriendAct; + QAction* removefriendAct; - LogoBar * _rsLogoBarmessenger; - - QFont itemFont; - - /** Qt Designer generated object */ - Ui::MessengerWindow ui; + QTreeView *messengertreeWidget; + + LogoBar * _rsLogoBarmessenger; + + QFont itemFont; + + /** Qt Designer generated object */ + Ui::MessengerWindow ui; }; #endif diff --git a/retroshare-gui/src/gui/MessengerWindow.ui b/retroshare-gui/src/gui/MessengerWindow.ui index c95f14569..157d91b6a 100644 --- a/retroshare-gui/src/gui/MessengerWindow.ui +++ b/retroshare-gui/src/gui/MessengerWindow.ui @@ -441,6 +441,9 @@ border: 1px solid #CCCCCC; 22 + + true + 0 @@ -489,6 +492,9 @@ border: 1px solid #CCCCCC; + + true + Set root is Decorated @@ -496,11 +502,6 @@ border: 1px solid #CCCCCC; Set Root Decorated - - - Set Root is not Decorated - - true @@ -509,6 +510,14 @@ border: 1px solid #CCCCCC; Hide Offline Friends + + + true + + + Sort by State + + diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index 64367f83a..a943a4bbb 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -77,24 +77,15 @@ #define COLUMN_INFO 2 #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 *****/ // quick and dirty for sorting, better use QTreeView and QSortFilterProxyModel -class MyTreeWidgetItem : public QTreeWidgetItem +class MyPeerTreeWidgetItem : public QTreeWidgetItem { public: - MyTreeWidgetItem(QTreeWidget *pWidget, int type) : QTreeWidgetItem(type) + MyPeerTreeWidgetItem(QTreeWidget *pWidget, int type) : QTreeWidgetItem(type) { 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( 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.mypersonalstatuslabel, SIGNAL(clicked()), SLOT(statusmessage())); @@ -263,12 +253,6 @@ PeersDialog::~PeersDialog () // save settings processSettings(false); - std::map::iterator it; - for (it = chatDialogs.begin(); it != chatDialogs.end(); it++) { - if (it->second) { - delete (it->second); - } - } delete smWidget; } @@ -437,11 +421,6 @@ void PeersDialog::updateDisplay() 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. */ void PeersDialog::insertPeers() { @@ -520,7 +499,7 @@ void PeersDialog::insertPeers() bool bNew = false; 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); bNew = true; } @@ -577,7 +556,7 @@ void PeersDialog::insertPeers() } 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 */ @@ -652,7 +631,7 @@ void PeersDialog::insertPeers() gpg_item->setHidden(false); gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_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::iterator 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 -> setToolTip(COLUMN_NAME, tr("Peer 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++) { gpg_item -> setTextColor(i,(Qt::gray)); gpg_item -> setFont(i,font); @@ -687,7 +666,7 @@ void PeersDialog::insertPeers() gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_ONLINE))); gpg_item -> setToolTip(COLUMN_NAME, tr("Peer 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++) { gpg_item -> setTextColor(i,(Qt::darkBlue)); gpg_item -> setFont(i,font); @@ -698,7 +677,7 @@ void PeersDialog::insertPeers() gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_AWAY))); gpg_item -> setToolTip(COLUMN_NAME, tr("Peer 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++) { gpg_item -> setTextColor(i,(Qt::gray)); gpg_item -> setFont(i,font); @@ -709,7 +688,7 @@ void PeersDialog::insertPeers() gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_BUSY))); gpg_item -> setToolTip(COLUMN_NAME, tr("Peer 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++) { gpg_item -> setTextColor(i,(Qt::gray)); gpg_item -> setFont(i,font); @@ -722,7 +701,7 @@ void PeersDialog::insertPeers() gpg_item->setHidden(bHideUnconnected); gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_AVAIBLE))); 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; font.setBold(true); for(i = 0; i < COLUMN_COUNT; i++) { @@ -733,7 +712,7 @@ void PeersDialog::insertPeers() gpg_item->setHidden(bHideUnconnected); gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_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; font.setBold(false); for(i = 0; i < COLUMN_COUNT; i++) { @@ -790,96 +769,32 @@ void PeersDialog::exportfriend() } -void PeersDialog::chatfriendproxy(){ - - QTreeWidgetItem* i = getCurrentPeer(); - - if(!i) - return; - - emit startChat(i); -} - -void PeersDialog::chatfriend(QTreeWidgetItem* currPeer) +void PeersDialog::chatfriendproxy() { - // QTreeWidgetItem *currPeer = 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 sslIds; - rsPeers->getSSLChildListOfGPGId(detail.gpg_id, sslIds); - for (std::list::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(); - } - } + chatfriend(getCurrentPeer()); } +void PeersDialog::chatfriend(QTreeWidgetItem *pPeer) +{ + if (pPeer == NULL) { + return; + } + + std::string id = (pPeer->text(COLUMN_ID)).toStdString(); + PopupChatDialog::chatFriend(id); +} void PeersDialog::msgfriend() { -#ifdef PEERS_DEBUG - std::cerr << "SharedFilesDialog::msgfriend()" << std::endl; -#endif + QTreeWidgetItem *peer = getCurrentPeer(); - QTreeWidgetItem *i = getCurrentPeer(); + if (!peer) + return; - if (!i) - return; - - std::string id = (i -> text(COLUMN_ID)).toStdString(); - - rsicontrol -> ClearInMsg(); - rsicontrol -> SetInMsg(id, true); - std::list sslIds; - rsPeers->getSSLChildListOfGPGId(id, sslIds); - for (std::list::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! */ + std::string id = (peer->text(COLUMN_ID)).toStdString(); + MessageComposer::msgFriend(id); } - QTreeWidgetItem *PeersDialog::getCurrentPeer() { /* 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 ; #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()); } @@ -1035,7 +950,7 @@ void PeersDialog::updatePeerStatusString(const QString& peer_id,const QString& s { 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); } else @@ -1085,7 +1000,7 @@ void PeersDialog::insertChat() /* are they 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)); playsound(); 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::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() { @@ -1623,8 +1454,7 @@ void PeersDialog::updateAvatar() pix.loadFromData(data,size,"PNG") ; ui.avatartoolButton->setIcon(pix); // writes image into ba in PNG format - for(std::map::const_iterator it(chatDialogs.begin());it!=chatDialogs.end();++it) - it->second->updateAvatar() ; + PopupChatDialog::updateAllAvatars(); delete[] data ; } diff --git a/retroshare-gui/src/gui/PeersDialog.h b/retroshare-gui/src/gui/PeersDialog.h index ad0837bf3..607e21f58 100644 --- a/retroshare-gui/src/gui/PeersDialog.h +++ b/retroshare-gui/src/gui/PeersDialog.h @@ -33,6 +33,17 @@ #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 QAction; class QTextEdit; @@ -49,9 +60,6 @@ public: /** Default Destructor */ ~PeersDialog (); - PopupChatDialog *getPrivateChat(std::string id, std::string name, uint chatflags); - void clearOldChats(); - void loadEmoticonsgroupchat(); // void setChatDialog(ChatDialog *cd); @@ -146,7 +154,6 @@ private slots: signals: void friendsUpdated() ; void notifyGroupChat(const QString&,const QString&) ; - void startChat(QTreeWidgetItem* ); private: void processSettings(bool bLoad); @@ -192,8 +199,6 @@ private: QHash smileys; QWidget *smWidget; - std::map chatDialogs; - QFont mCurrentFont; /* how the text will come out */ /** Qt Designer generated object */ diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 04b76ecee..a837d6bec 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -29,10 +29,12 @@ #include "rsiface/rspeers.h" #include "rsiface/rsmsgs.h" #include "rsiface/rsfiles.h" +#include "rsiface/rsnotify.h" #include "gui/settings/rsharesettings.h" #include "gui/feeds/AttachFileItem.h" +#include "gui/msgs/MessageComposer.h" #include #define appDir QApplication::applicationDirPath() @@ -46,6 +48,8 @@ * #define CHAT_DEBUG 1 *****/ +static std::map chatDialogs; + /** Default constructor */ PopupChatDialog::PopupChatDialog(std::string id, std::string name, QWidget *parent, Qt::WFlags flags) @@ -140,6 +144,145 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name, 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::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::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 sslIds; + rsPeers->getSSLChildListOfGPGId(detail.gpg_id, sslIds); + for (std::list::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::const_iterator it(chatDialogs.begin());it!=chatDialogs.end();++it) + it->second->updateAvatar() ; +} + void PopupChatDialog::pasteLink() { std::cerr << "In paste link" << std::endl ; diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.h b/retroshare-gui/src/gui/chat/PopupChatDialog.h index 72890fb52..d58886ff0 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.h @@ -44,11 +44,10 @@ class PopupChatDialog : public QMainWindow Q_OBJECT public: - /** Default constructor */ - PopupChatDialog(std::string id, std::string name, - QWidget *parent = 0, Qt::WFlags flags = 0); - /** Default destructor */ - ~PopupChatDialog(); + static PopupChatDialog *getPrivateChat(std::string id, std::string name, uint chatflags); + static void cleanupChat(); + static void chatFriend(std::string id); + static void updateAllAvatars(); void updateChat(); void updatePeerAvatar(const std::string&); @@ -85,6 +84,12 @@ public slots: protected: + /** Default constructor */ + PopupChatDialog(std::string id, std::string name, + QWidget *parent = 0, Qt::WFlags flags = 0); + /** Default destructor */ + ~PopupChatDialog(); + void closeEvent (QCloseEvent * event); virtual void dragEnterEvent(QDragEnterEvent *event); virtual void dropEvent(QDropEvent *event); diff --git a/retroshare-gui/src/gui/common/rwindow.h b/retroshare-gui/src/gui/common/rwindow.h index 5811809f4..14d85c2ad 100644 --- a/retroshare-gui/src/gui/common/rwindow.h +++ b/retroshare-gui/src/gui/common/rwindow.h @@ -66,8 +66,10 @@ signals: * topic. */ void helpRequested(const QString &topic); -private: +protected: QString _name; /**< Name associated with this window. */ + +private: bool m_bSaveStateOnClose; // is set to true in restoreWindowState }; diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 3b807b44a..f1b301761 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -197,6 +197,30 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags) #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 sslIds; + rsPeers->getSSLChildListOfGPGId(id, sslIds); + for (std::list::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) { bool bClose = true; diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index 5bc4c8ff1..e6555f587 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -46,6 +46,8 @@ public: MessageComposer(QWidget *parent = 0, Qt::WFlags flags = 0); + static void msgFriend(std::string id); + void newMsg(std::string msgId = ""); /* worker fns */ diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 297f12129..f09361963 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -175,7 +175,6 @@ int main(int argc, char *argv[]) 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))); /* only show window, if not startMinimized */ @@ -194,6 +193,9 @@ int main(int argc, char *argv[]) int ti = rshare.exec(); delete w ; + /* cleanup */ + PopupChatDialog::cleanupChat(); + rsicontrol->rsGlobalShutDown(); Settings->sync();