redesigned the Chatlobby participants list

- used now QTreeWidget instead of a QListWidget
- added icons for display the muted participants
- added context menu for "Mute participant" ( context menu fix from thunder)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5818 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2012-11-14 14:39:08 +00:00
parent d3a3efd492
commit 40b80c4e84
3 changed files with 93 additions and 21 deletions

View file

@ -22,6 +22,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QInputDialog> #include <QInputDialog>
#include <QMenu>
#include "ChatLobbyDialog.h" #include "ChatLobbyDialog.h"
#include "ChatTabWidget.h" #include "ChatTabWidget.h"
@ -30,7 +31,7 @@
#include "gui/MainWindow.h" #include "gui/MainWindow.h"
#include "gui/FriendsDialog.h" #include "gui/FriendsDialog.h"
#include <gui/common/html.h> #include <gui/common/html.h>
#include "gui/common/RSListWidgetItem.h" #include "gui/common/RSTreeWidgetItem.h"
#include <retroshare/rsnotify.h> #include <retroshare/rsnotify.h>
@ -45,9 +46,31 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WF
connect(ui.participantsFrameButton, SIGNAL(toggled(bool)), this, SLOT(showParticipantsFrame(bool))); connect(ui.participantsFrameButton, SIGNAL(toggled(bool)), this, SLOT(showParticipantsFrame(bool)));
connect(ui.actionChangeNickname, SIGNAL(triggered()), this, SLOT(changeNickname())); connect(ui.actionChangeNickname, SIGNAL(triggered()), this, SLOT(changeNickname()));
connect(ui.participantsList, SIGNAL( customContextMenuRequested(QPoint)), this, SLOT( participantsTreeWidgetCostumPopupMenu(QPoint)));
ui.participantsList->setRootIsDecorated(false);
// Mute a Participant // Mute a Participant
connect(ui.participantsList, SIGNAL(itemClicked(QListWidgetItem *)), SLOT(changePartipationState(QListWidgetItem *))); muteAct = new QAction(QIcon(), tr("Mute participant"), this);
connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState()));
}
void ChatLobbyDialog::participantsTreeWidgetCostumPopupMenu(QPoint)
{
QTreeWidgetItem *item = getCurrentParticipant();
QMenu contextMnu(this);
contextMnu.addAction(muteAct);
muteAct->setEnabled(item != NULL);
muteAct->setCheckable(true);
if (item) {
muteAct->setChecked(isParticipantMuted(item->text(0)));
} else {
muteAct->setChecked(false);
}
contextMnu.exec(QCursor::pos());
} }
void ChatLobbyDialog::init(const std::string &peerId, const QString &title) void ChatLobbyDialog::init(const std::string &peerId, const QString &title)
@ -210,7 +233,7 @@ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
} }
/** /**
* Regenerate the QListWidget participant list of a Chat Lobby * Regenerate the QTreeWidget participant list of a Chat Lobby
* *
* Show unchecked Checkbox for muted Participants * Show unchecked Checkbox for muted Participants
*/ */
@ -232,40 +255,43 @@ void ChatLobbyDialog::updateParticipantsList()
QString participant = QString::fromUtf8( (it2->first).c_str() ); QString participant = QString::fromUtf8( (it2->first).c_str() );
// TE: Add Wigdet to participantsList with Checkbox, to mute Participant // TE: Add Wigdet to participantsList with Checkbox, to mute Participant
QListWidgetItem *widgetitem = new RSListWidgetItem; QTreeWidgetItem *widgetitem = new RSTreeWidgetItem;
if (isParticipantMuted(participant)) { if (isParticipantMuted(participant)) {
widgetitem->setCheckState(Qt::Unchecked); widgetitem->setIcon(0,(QIcon(":/images/yellowled.png")));
} else { } else {
widgetitem->setCheckState(Qt::Checked); widgetitem->setIcon(0,(QIcon(":/images/greenled.png")));
} }
widgetitem->setText(participant); widgetitem->setText(0, participant);
widgetitem->setToolTip(tr("Uncheck to mute participant")); widgetitem->setToolTip(0,(tr("right click,and check to mute participant")));
ui.participantsList->addItem(widgetitem); ui.participantsList->addTopLevelItem(widgetitem);
} }
} }
ui.participantsList->setSortingEnabled(true); ui.participantsList->setSortingEnabled(true);
ui.participantsList->sortItems(Qt::AscendingOrder); ui.participantsList->sortItems(0, Qt::AscendingOrder);
} }
/** /**
* Called when a Participant in QList get Clicked / Changed * Called when a Participant in QTree get Clicked / Changed
* *
* Check if the Checkbox altered and Mute User * Check if the Checkbox altered and Mute User
* *
* @todo auf rsid * @todo auf rsid
* *
* @param QListWidgetItem Participant to check * @param QTreeWidgetItem Participant to check
*/ */
void ChatLobbyDialog::changePartipationState(QListWidgetItem *item) void ChatLobbyDialog::changePartipationState()
{ {
QString nickname = item->text(); QTreeWidgetItem *item = getCurrentParticipant();
if (!item)
return;
QString nickname = item->text(0);
std::cerr << "check Partipation status for '" << nickname.toStdString() << std::endl; std::cerr << "check Partipation status for '" << nickname.toStdString() << std::endl;
if (item->checkState() == Qt::Unchecked) { if (muteAct->isChecked()) {
muteParticipant(nickname); muteParticipant(nickname);
} else { } else {
unMuteParticipant(nickname); unMuteParticipant(nickname);
@ -398,3 +424,13 @@ void ChatLobbyDialog::showParticipantsFrame(bool show)
PeerSettings->setShowParticipantsFrame(getPeerId(), show); PeerSettings->setShowParticipantsFrame(getPeerId(), show);
} }
QTreeWidgetItem *ChatLobbyDialog::getCurrentParticipant()
{
if (ui.participantsList->selectedItems().size() != 0) {
return ui.participantsList->currentItem();
}
return NULL;
}

View file

@ -43,6 +43,7 @@ public:
private slots: private slots:
void showParticipantsFrame(bool show); void showParticipantsFrame(bool show);
void participantsTreeWidgetCostumPopupMenu( QPoint point );
protected: protected:
/** Default constructor */ /** Default constructor */
@ -59,9 +60,11 @@ protected:
protected slots: protected slots:
void changeNickname(); void changeNickname();
void changePartipationState(QListWidgetItem *item); void changePartipationState();
private: private:
QTreeWidgetItem *getCurrentParticipant();
void updateParticipantsList(); void updateParticipantsList();
void muteParticipant(const QString &nickname); void muteParticipant(const QString &nickname);
@ -79,7 +82,7 @@ private:
/** Ignored Users in Chatlobby by nickname until we had implemented Peer Ids in ver 0.6 */ /** Ignored Users in Chatlobby by nickname until we had implemented Peer Ids in ver 0.6 */
QStringList *mutedParticipants; QStringList *mutedParticipants;
QAction *muteAct;
}; };
#endif #endif

View file

@ -115,7 +115,40 @@
<number>3</number> <number>3</number>
</property> </property>
<item> <item>
<widget class="QListWidget" name="participantsList"/> <widget class="QTreeWidget" name="participantsList">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="animated">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="headerHidden">
<bool>false</bool>
</property>
<attribute name="headerVisible">
<bool>true</bool>
</attribute>
<attribute name="headerVisible">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>Participants</string>
</property>
</column>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>