Moved the chat lobby tabs to the FriendsDialog.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4811 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-01-18 20:02:19 +00:00
parent 1ec716175b
commit 912e5339ca
12 changed files with 73 additions and 101 deletions

View File

@ -29,24 +29,17 @@
#define IMAGE_SUBSCRIBE "" #define IMAGE_SUBSCRIBE ""
#define IMAGE_UNSUBSCRIBE "" #define IMAGE_UNSUBSCRIBE ""
static ChatLobbyWidget *instance = NULL;
ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WFlags flags) ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WFlags flags)
: RsAutoUpdatePage(5000,parent) : RsAutoUpdatePage(5000,parent)
{ {
setupUi(this); setupUi(this);
if (instance == NULL) {
instance = this;
}
QObject::connect(NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged())); QObject::connect(NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged()));
QObject::connect(NotifyQt::getInstance(), SIGNAL(chatLobbyEvent(qulonglong,int,const QString&,const QString&)), this, SLOT(displayChatLobbyEvent(qulonglong,int,const QString&,const QString&))); QObject::connect(NotifyQt::getInstance(), SIGNAL(chatLobbyEvent(qulonglong,int,const QString&,const QString&)), this, SLOT(displayChatLobbyEvent(qulonglong,int,const QString&,const QString&)));
QObject::connect(NotifyQt::getInstance(), SIGNAL(chatLobbyInviteReceived()), this, SLOT(readChatLobbyInvites())); QObject::connect(NotifyQt::getInstance(), SIGNAL(chatLobbyInviteReceived()), this, SLOT(readChatLobbyInvites()));
QObject::connect(lobbyTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(lobbyTreeWidgetCostumPopupMenu())); QObject::connect(lobbyTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(lobbyTreeWidgetCostumPopupMenu()));
QObject::connect(lobbyTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int))); QObject::connect(lobbyTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int)));
QObject::connect(lobbyTabWidget, SIGNAL(infoChanged()), this, SLOT(tabInfoChanged()));
QObject::connect(newlobbypushButton, SIGNAL(clicked()), this, SLOT(createChatLobby())); QObject::connect(newlobbypushButton, SIGNAL(clicked()), this, SLOT(createChatLobby()));
@ -86,14 +79,6 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WFlags flags)
ChatLobbyWidget::~ChatLobbyWidget() ChatLobbyWidget::~ChatLobbyWidget()
{ {
if (this == instance) {
instance = NULL;
}
}
/*static*/ ChatTabWidget *ChatLobbyWidget::getTabWidget()
{
return instance ? instance->lobbyTabWidget : NULL;
} }
void ChatLobbyWidget::lobbyTreeWidgetCostumPopupMenu() void ChatLobbyWidget::lobbyTreeWidgetCostumPopupMenu()
@ -367,13 +352,3 @@ void ChatLobbyWidget::readChatLobbyInvites()
} }
} }
} }
void ChatLobbyWidget::tabInfoChanged()
{
emit infoChanged();
}
void ChatLobbyWidget::getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon)
{
lobbyTabWidget->getInfo(isTyping, hasNewMessage, icon);
}

View File

@ -4,7 +4,6 @@
#include "RsAutoUpdatePage.h" #include "RsAutoUpdatePage.h"
class RSTreeWidgetItemCompareRole; class RSTreeWidgetItemCompareRole;
class ChatTabWidget;
class ChatLobbyWidget : public RsAutoUpdatePage, Ui::ChatLobbyWidget class ChatLobbyWidget : public RsAutoUpdatePage, Ui::ChatLobbyWidget
{ {
@ -18,12 +17,6 @@ public:
~ChatLobbyWidget(); ~ChatLobbyWidget();
virtual void updateDisplay(); virtual void updateDisplay();
void getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon);
static ChatTabWidget *getTabWidget();
signals:
void infoChanged();
protected slots: protected slots:
void lobbyChanged(); void lobbyChanged();
@ -34,7 +27,6 @@ protected slots:
void itemDoubleClicked(QTreeWidgetItem *item, int column); void itemDoubleClicked(QTreeWidgetItem *item, int column);
void displayChatLobbyEvent(qulonglong lobby_id, int event_type, const QString& nickname, const QString& str); void displayChatLobbyEvent(qulonglong lobby_id, int event_type, const QString& nickname, const QString& str);
void readChatLobbyInvites(); void readChatLobbyInvites();
void tabInfoChanged();
private: private:
RSTreeWidgetItemCompareRole *compareRole; RSTreeWidgetItemCompareRole *compareRole;

View File

@ -174,22 +174,11 @@ p, li { white-space: pre-wrap; }
</layout> </layout>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="ChatTabWidget" name="lobbyTabWidget"> <widget class="QWidget" name="lobbyInfo">
<property name="currentIndex">
<number>-1</number>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>ChatTabWidget</class>
<extends>QTabWidget</extends>
<header location="global">gui/chat/ChatTabWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources> <resources>
<include location="images.qrc"/> <include location="images.qrc"/>
</resources> </resources>

View File

@ -68,6 +68,8 @@
* #define FRIENDS_DEBUG 1 * #define FRIENDS_DEBUG 1
*****/ *****/
static FriendsDialog *instance = NULL;
/** Constructor */ /** Constructor */
FriendsDialog::FriendsDialog(QWidget *parent) FriendsDialog::FriendsDialog(QWidget *parent)
: RsAutoUpdatePage(1500,parent) : RsAutoUpdatePage(1500,parent)
@ -75,6 +77,10 @@ FriendsDialog::FriendsDialog(QWidget *parent)
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
if (instance == NULL) {
instance = this;
}
last_status_send_time = 0 ; last_status_send_time = 0 ;
connect( ui.mypersonalstatuslabel, SIGNAL(clicked()), SLOT(statusmessage())); connect( ui.mypersonalstatuslabel, SIGNAL(clicked()), SLOT(statusmessage()));
@ -87,18 +93,20 @@ FriendsDialog::FriendsDialog(QWidget *parent)
ui.avatar->setFrameType(AvatarWidget::STATUS_FRAME); ui.avatar->setFrameType(AvatarWidget::STATUS_FRAME);
ui.avatar->setOwnId(); ui.avatar->setOwnId();
chatLobbyWidget = new ChatLobbyWidget(); ui.tabWidget->setTabPosition(QTabWidget::North);
QObject::connect(chatLobbyWidget, SIGNAL(infoChanged()), this, SLOT(lobbyInfoChanged())); ui.tabWidget->addTab(new ChatLobbyWidget(), tr("Chat lobbies"));
chatlobbyTabIndex = ui.peertabWidget->addTab(chatLobbyWidget, tr("Chat lobbies")); ui.tabWidget->addTab(new ProfileWidget(), tr("Profile"));
ui.peertabWidget->setTabPosition(QTabWidget::North);
ui.peertabWidget->addTab(new ProfileWidget(), tr("Profile"));
NewsFeed *newsFeed = new NewsFeed(); NewsFeed *newsFeed = new NewsFeed();
newsFeedTabIndex = ui.peertabWidget->addTab(newsFeed, tr("News Feed")); newsFeedTabIndex = ui.tabWidget->addTab(newsFeed, tr("News Feed"));
ui.peertabWidget->tabBar()->setIconSize(QSize(10, 10));
ui.tabWidget->hideCloseButton(0);
ui.tabWidget->hideCloseButton(1);
ui.tabWidget->hideCloseButton(2);
ui.tabWidget->hideCloseButton(3);
/* get the current text and text color of the tab bar */ /* get the current text and text color of the tab bar */
newsFeedTabColor = ui.peertabWidget->tabBar()->tabTextColor(newsFeedTabIndex); newsFeedTabColor = ui.tabWidget->tabBar()->tabTextColor(newsFeedTabIndex);
newsFeedText = ui.peertabWidget->tabBar()->tabText(newsFeedTabIndex); newsFeedText = ui.tabWidget->tabBar()->tabText(newsFeedTabIndex);
connect(newsFeed, SIGNAL(newsFeedChanged(int)), this, SLOT(newsFeedChanged(int))); connect(newsFeed, SIGNAL(newsFeedChanged(int)), this, SLOT(newsFeedChanged(int)));
@ -206,6 +214,10 @@ FriendsDialog::~FriendsDialog ()
{ {
// save settings // save settings
processSettings(false); processSettings(false);
if (this == instance) {
instance = NULL;
}
} }
void FriendsDialog::processSettings(bool bLoad) void FriendsDialog::processSettings(bool bLoad)
@ -810,28 +822,23 @@ void FriendsDialog::on_actionAdd_Group_activated()
void FriendsDialog::newsFeedChanged(int count) void FriendsDialog::newsFeedChanged(int count)
{ {
if (count) { if (count) {
ui.peertabWidget->tabBar()->setTabText(newsFeedTabIndex, QString("%1 (%2)").arg(newsFeedText).arg(count)); ui.tabWidget->tabBar()->setTabText(newsFeedTabIndex, QString("%1 (%2)").arg(newsFeedText).arg(count));
ui.peertabWidget->tabBar()->setTabTextColor(newsFeedTabIndex, Qt::blue); ui.tabWidget->tabBar()->setTabTextColor(newsFeedTabIndex, Qt::blue);
ui.peertabWidget->tabBar()->setTabIcon(newsFeedTabIndex, QIcon(IMAGE_NEWSFEED_NEW)); ui.tabWidget->tabBar()->setTabIcon(newsFeedTabIndex, QIcon(IMAGE_NEWSFEED_NEW));
} else { } else {
ui.peertabWidget->tabBar()->setTabText(newsFeedTabIndex, newsFeedText); ui.tabWidget->tabBar()->setTabText(newsFeedTabIndex, newsFeedText);
ui.peertabWidget->tabBar()->setTabTextColor(newsFeedTabIndex, newsFeedTabColor); ui.tabWidget->tabBar()->setTabTextColor(newsFeedTabIndex, newsFeedTabColor);
ui.peertabWidget->tabBar()->setTabIcon(newsFeedTabIndex, QIcon(IMAGE_NEWSFEED)); ui.tabWidget->tabBar()->setTabIcon(newsFeedTabIndex, QIcon(IMAGE_NEWSFEED));
} }
} }
void FriendsDialog::lobbyInfoChanged()
{
bool isTyping;
bool hasNewMessage;
QIcon icon;
chatLobbyWidget->getInfo(isTyping, hasNewMessage, &icon);
ui.peertabWidget->setTabIcon(chatlobbyTabIndex, icon);
}
void FriendsDialog::createChatLobby() void FriendsDialog::createChatLobby()
{ {
std::list<std::string> friends; std::list<std::string> friends;
CreateLobbyDialog(friends).exec(); CreateLobbyDialog(friends).exec();
} }
/*static*/ ChatTabWidget *FriendsDialog::getTabWidget()
{
return instance ? instance->ui.tabWidget : NULL;
}

View File

@ -27,7 +27,6 @@
#include "mainpage.h" #include "mainpage.h"
#ifndef MINIMAL_RSGUI #ifndef MINIMAL_RSGUI
#include "ui_FriendsDialog.h" #include "ui_FriendsDialog.h"
@ -35,8 +34,7 @@ class QFont;
class QAction; class QAction;
class QTextEdit; class QTextEdit;
class QTextCharFormat; class QTextCharFormat;
class ChatDialog; class ChatTabWidget;
class ChatLobbyWidget;
class FriendsDialog : public RsAutoUpdatePage class FriendsDialog : public RsAutoUpdatePage
{ {
@ -50,6 +48,8 @@ public:
virtual void updateDisplay() ; // overloaded from RsAutoUpdatePage virtual void updateDisplay() ; // overloaded from RsAutoUpdatePage
static ChatTabWidget *getTabWidget();
public slots: public slots:
void publicChatChanged(int type); void publicChatChanged(int type);
@ -112,8 +112,6 @@ private slots:
void newsFeedChanged(int count); void newsFeedChanged(int count);
void lobbyInfoChanged();
void createChatLobby(); void createChatLobby();
signals: signals:
@ -142,9 +140,6 @@ private:
QColor newsFeedTabColor; QColor newsFeedTabColor;
QString newsFeedText; QString newsFeedText;
ChatLobbyWidget *chatLobbyWidget;
int chatlobbyTabIndex;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::FriendsDialog ui; Ui::FriendsDialog ui;
}; };

View File

@ -810,10 +810,13 @@ p, li { white-space: pre-wrap; }
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="RSTabWidget" name="peertabWidget"> <widget class="ChatTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>0</number>
</property> </property>
<property name="tabsClosable">
<bool>true</bool>
</property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
<string>Group Chat</string> <string>Group Chat</string>
@ -1441,6 +1444,12 @@ background: white;}</string>
</action> </action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>ChatTabWidget</class>
<extends>QTabWidget</extends>
<header location="global">gui/chat/ChatTabWidget.h</header>
<container>1</container>
</customwidget>
<customwidget> <customwidget>
<class>AvatarWidget</class> <class>AvatarWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
@ -1453,12 +1462,6 @@ background: white;}</string>
<header location="global">gui/common/HashBox.h</header> <header location="global">gui/common/HashBox.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>RSTabWidget</class>
<extends>QTabWidget</extends>
<header>gui/common/RSTabWidget.h</header>
<container>1</container>
</customwidget>
<customwidget> <customwidget>
<class>FriendList</class> <class>FriendList</class>
<extends>QWidget</extends> <extends>QWidget</extends>

View File

@ -300,11 +300,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
ui.messagestreeView->installEventFilter(this); ui.messagestreeView->installEventFilter(this);
// remove close button of the the first tab // remove close button of the the first tab
QTabBar::ButtonPosition buttonPosition = (QTabBar::ButtonPosition) ui.tabWidget->tabBar()->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, 0); ui.tabWidget->hideCloseButton(0);
QWidget *tabButton = ui.tabWidget->tabBar()->tabButton(0, buttonPosition);
if (tabButton) {
tabButton->hide();
}
/* Hide platform specific features */ /* Hide platform specific features */
#ifdef Q_WS_WIN #ifdef Q_WS_WIN

View File

@ -23,9 +23,10 @@
#include <QMessageBox> #include <QMessageBox>
#include "ChatLobbyDialog.h" #include "ChatLobbyDialog.h"
#include "gui/ChatLobbyWidget.h" #include "ChatTabWidget.h"
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "gui/settings/RsharePeerSettings.h" #include "gui/settings/RsharePeerSettings.h"
#include "gui/FriendsDialog.h"
#include <retroshare/rsnotify.h> #include <retroshare/rsnotify.h>
@ -55,7 +56,7 @@ void ChatLobbyDialog::init(const std::string &peerId, const QString &title)
showParticipantsFrame(PeerSettings->getShowParticipantsFrame(peerId)); showParticipantsFrame(PeerSettings->getShowParticipantsFrame(peerId));
// add to window // add to window
ChatTabWidget *tabWidget = ChatLobbyWidget::getTabWidget(); ChatTabWidget *tabWidget = FriendsDialog::getTabWidget();
if (tabWidget) { if (tabWidget) {
tabWidget->addDialog(this); tabWidget->addDialog(this);
} }
@ -174,7 +175,7 @@ bool ChatLobbyDialog::canClose()
void ChatLobbyDialog::showDialog(uint chatflags) void ChatLobbyDialog::showDialog(uint chatflags)
{ {
if (chatflags & RS_CHAT_FOCUS) { if (chatflags & RS_CHAT_FOCUS) {
ChatTabWidget *tabWidget = ChatLobbyWidget::getTabWidget(); ChatTabWidget *tabWidget = FriendsDialog::getTabWidget();
if (tabWidget) { if (tabWidget) {
tabWidget->setCurrentWidget(this); tabWidget->setCurrentWidget(this);
} }

View File

@ -30,7 +30,7 @@
#define IMAGE_CHAT ":/images/chat.png" #define IMAGE_CHAT ":/images/chat.png"
ChatTabWidget::ChatTabWidget(QWidget *parent) : ChatTabWidget::ChatTabWidget(QWidget *parent) :
QTabWidget(parent), RSTabWidget(parent),
ui(new Ui::ChatTabWidget) ui(new Ui::ChatTabWidget)
{ {
ui->setupUi(this); ui->setupUi(this);

View File

@ -23,7 +23,7 @@
#ifndef CHATTABWIDGET_H #ifndef CHATTABWIDGET_H
#define CHATTABWIDGET_H #define CHATTABWIDGET_H
#include <QTabWidget> #include "gui/common/RSTabWidget.h"
namespace Ui { namespace Ui {
class ChatTabWidget; class ChatTabWidget;
@ -31,7 +31,7 @@ class ChatTabWidget;
class ChatDialog; class ChatDialog;
class ChatTabWidget : public QTabWidget class ChatTabWidget : public RSTabWidget
{ {
Q_OBJECT Q_OBJECT

View File

@ -19,6 +19,9 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#include <QTabBar>
#include <QStyle>
#include "RSTabWidget.h" #include "RSTabWidget.h"
RSTabWidget::RSTabWidget(QWidget *parent) : QTabWidget(parent) RSTabWidget::RSTabWidget(QWidget *parent) : QTabWidget(parent)
@ -27,5 +30,14 @@ RSTabWidget::RSTabWidget(QWidget *parent) : QTabWidget(parent)
QTabBar *RSTabWidget::tabBar() const QTabBar *RSTabWidget::tabBar() const
{ {
return QTabWidget::tabBar(); return QTabWidget::tabBar();
}; }
void RSTabWidget::hideCloseButton(int index)
{
QTabBar::ButtonPosition buttonPosition = (QTabBar::ButtonPosition) tabBar()->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, 0);
QWidget *tabButton = tabBar()->tabButton(index, buttonPosition);
if (tabButton) {
tabButton->hide();
}
}

View File

@ -28,10 +28,12 @@
class RSTabWidget : public QTabWidget class RSTabWidget : public QTabWidget
{ {
public: public:
RSTabWidget(QWidget *parent = 0); RSTabWidget(QWidget *parent = 0);
void hideCloseButton(int index);
public: public:
QTabBar *tabBar() const; QTabBar *tabBar() const;
}; };
#endif #endif