mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-05 21:04:14 -04:00
added a new class FriendSelectionDialog with a sstatic method to select friends in a modal dialog. Used it to add a "invite friends" button to chatLobbyDialog
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-ImprovedGUI@6125 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
205828bc7d
commit
d875fa2e07
7 changed files with 111 additions and 1 deletions
|
@ -33,6 +33,7 @@
|
|||
#include "gui/FriendsDialog.h"
|
||||
#include <gui/common/html.h>
|
||||
#include "gui/common/RSTreeWidgetItem.h"
|
||||
#include "gui/common/FriendSelectionDialog.h"
|
||||
|
||||
#include <retroshare/rsnotify.h>
|
||||
|
||||
|
@ -57,9 +58,45 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WF
|
|||
ui.participantsList->setColumnCount(COLUMN_COUNT);
|
||||
ui.participantsList->setColumnWidth(COLUMN_ICON, 20);
|
||||
|
||||
// Mute a Participant
|
||||
muteAct = new QAction(QIcon(), tr("Mute participant"), this);
|
||||
connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState()));
|
||||
|
||||
// Add a button to invite friends.
|
||||
//
|
||||
inviteFriendsButton = new QPushButton ;
|
||||
inviteFriendsButton->setMinimumSize(QSize(28,28)) ;
|
||||
inviteFriendsButton->setMaximumSize(QSize(28,28)) ;
|
||||
inviteFriendsButton->setText(QString()) ;
|
||||
inviteFriendsButton->setToolTip(tr("Invite friends to this lobby"));
|
||||
|
||||
QIcon icon ;
|
||||
icon.addPixmap(QPixmap(":/images/edit_add24.png")) ;
|
||||
inviteFriendsButton->setIcon(icon) ;
|
||||
inviteFriendsButton->setIconSize(QSize(22,22)) ;
|
||||
|
||||
connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends()));
|
||||
|
||||
getChatWidget()->addChatButton(inviteFriendsButton) ;
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::inviteFriends()
|
||||
{
|
||||
std::cerr << "Inviting friends" << std::endl;
|
||||
|
||||
std::list<std::string> ids = FriendSelectionDialog::selectFriends() ;
|
||||
|
||||
std::cerr << "Inviting these friends:" << std::endl;
|
||||
|
||||
ChatLobbyId lobby_id;
|
||||
if (!rsMsgs->isLobbyId(getPeerId(), lobby_id))
|
||||
return ;
|
||||
|
||||
for(std::list<std::string>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
{
|
||||
std::cerr << " " << *it << std::endl;
|
||||
|
||||
rsMsgs->invitePeerToLobby(lobby_id,*it) ;
|
||||
}
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::participantsTreeWidgetCostumPopupMenu(QPoint)
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
private slots:
|
||||
void showParticipantsFrame(bool show);
|
||||
void participantsTreeWidgetCostumPopupMenu( QPoint point );
|
||||
void inviteFriends() ;
|
||||
|
||||
protected:
|
||||
/** Default constructor */
|
||||
|
@ -75,6 +76,8 @@ private:
|
|||
QString _lobby_name ;
|
||||
time_t lastUpdateListTime;
|
||||
|
||||
QPushButton *inviteFriendsButton ;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::ChatLobbyDialog ui;
|
||||
|
||||
|
|
48
retroshare-gui/src/gui/common/FriendSelectionDialog.cpp
Normal file
48
retroshare-gui/src/gui/common/FriendSelectionDialog.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#include <list>
|
||||
|
||||
#include <QLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include "FriendSelectionDialog.h"
|
||||
|
||||
std::list<std::string> FriendSelectionDialog::selectFriends()
|
||||
{
|
||||
FriendSelectionDialog dialog ;
|
||||
dialog.friends_widget->start() ;
|
||||
dialog.setWindowTitle(tr("Choose some friends")) ;
|
||||
|
||||
if(QDialog::Rejected == dialog.exec())
|
||||
return std::list<std::string>() ;
|
||||
|
||||
std::list<std::string> ids ;
|
||||
dialog.friends_widget->selectedSslIds(ids,false) ;
|
||||
|
||||
return ids ;
|
||||
}
|
||||
|
||||
FriendSelectionDialog::FriendSelectionDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
friends_widget = new FriendSelectionWidget(this) ;
|
||||
|
||||
friends_widget->setHeaderText(tr("Contacts:"));
|
||||
friends_widget->setModus(FriendSelectionWidget::MODUS_CHECK);
|
||||
friends_widget->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
|
||||
|
||||
QLayout *l = new QVBoxLayout ;
|
||||
setLayout(l) ;
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
l->addWidget(friends_widget) ;
|
||||
l->addWidget(buttonBox) ;
|
||||
l->update() ;
|
||||
}
|
||||
|
||||
FriendSelectionDialog::~FriendSelectionDialog()
|
||||
{
|
||||
delete friends_widget ;
|
||||
}
|
||||
|
17
retroshare-gui/src/gui/common/FriendSelectionDialog.h
Normal file
17
retroshare-gui/src/gui/common/FriendSelectionDialog.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <gui/common/FriendSelectionWidget.h>
|
||||
|
||||
class FriendSelectionDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
static std::list<std::string> selectFriends() ;
|
||||
|
||||
private:
|
||||
virtual ~FriendSelectionDialog() ;
|
||||
FriendSelectionDialog(QWidget *parent = NULL) ;
|
||||
|
||||
FriendSelectionWidget *friends_widget ;
|
||||
};
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include "FriendSelectionWidget.h"
|
||||
#include "ui_FriendSelectionWidget.h"
|
||||
#include "gui/notifyqt.h"
|
||||
|
@ -835,3 +836,4 @@ std::string FriendSelectionWidget::idFromItem(QTreeWidgetItem *item)
|
|||
|
||||
return item->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#define FRIENDSELECTIONWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class FriendSelectionWidget;
|
||||
|
|
|
@ -411,6 +411,7 @@ HEADERS += rshare.h \
|
|||
gui/common/AvatarWidget.h \
|
||||
gui/common/FriendList.h \
|
||||
gui/common/FriendSelectionWidget.h \
|
||||
gui/common/FriendSelectionDialog.h \
|
||||
gui/common/HashBox.h \
|
||||
gui/common/LineEditClear.h \
|
||||
gui/common/DropLineEdit.h \
|
||||
|
@ -682,6 +683,7 @@ SOURCES += main.cpp \
|
|||
gui/common/AvatarWidget.cpp \
|
||||
gui/common/FriendList.cpp \
|
||||
gui/common/FriendSelectionWidget.cpp \
|
||||
gui/common/FriendSelectionDialog.cpp \
|
||||
gui/common/HashBox.cpp \
|
||||
gui/common/LineEditClear.cpp \
|
||||
gui/common/DropLineEdit.cpp \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue