mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
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:
parent
1ec716175b
commit
912e5339ca
@ -29,25 +29,18 @@
|
||||
#define IMAGE_SUBSCRIBE ""
|
||||
#define IMAGE_UNSUBSCRIBE ""
|
||||
|
||||
static ChatLobbyWidget *instance = NULL;
|
||||
|
||||
ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WFlags flags)
|
||||
: RsAutoUpdatePage(5000,parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
if (instance == NULL) {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
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(chatLobbyInviteReceived()), this, SLOT(readChatLobbyInvites()));
|
||||
|
||||
QObject::connect(lobbyTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(lobbyTreeWidgetCostumPopupMenu()));
|
||||
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()));
|
||||
|
||||
compareRole = new RSTreeWidgetItemCompareRole;
|
||||
@ -86,14 +79,6 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WFlags flags)
|
||||
|
||||
ChatLobbyWidget::~ChatLobbyWidget()
|
||||
{
|
||||
if (this == instance) {
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ ChatTabWidget *ChatLobbyWidget::getTabWidget()
|
||||
{
|
||||
return instance ? instance->lobbyTabWidget : NULL;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "RsAutoUpdatePage.h"
|
||||
|
||||
class RSTreeWidgetItemCompareRole;
|
||||
class ChatTabWidget;
|
||||
|
||||
class ChatLobbyWidget : public RsAutoUpdatePage, Ui::ChatLobbyWidget
|
||||
{
|
||||
@ -18,12 +17,6 @@ public:
|
||||
~ChatLobbyWidget();
|
||||
|
||||
virtual void updateDisplay();
|
||||
void getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon);
|
||||
|
||||
static ChatTabWidget *getTabWidget();
|
||||
|
||||
signals:
|
||||
void infoChanged();
|
||||
|
||||
protected slots:
|
||||
void lobbyChanged();
|
||||
@ -34,7 +27,6 @@ protected slots:
|
||||
void itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
void displayChatLobbyEvent(qulonglong lobby_id, int event_type, const QString& nickname, const QString& str);
|
||||
void readChatLobbyInvites();
|
||||
void tabInfoChanged();
|
||||
|
||||
private:
|
||||
RSTreeWidgetItemCompareRole *compareRole;
|
||||
|
@ -174,22 +174,11 @@ p, li { white-space: pre-wrap; }
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="ChatTabWidget" name="lobbyTabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="lobbyInfo">
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ChatTabWidget</class>
|
||||
<extends>QTabWidget</extends>
|
||||
<header location="global">gui/chat/ChatTabWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
</resources>
|
||||
|
@ -68,6 +68,8 @@
|
||||
* #define FRIENDS_DEBUG 1
|
||||
*****/
|
||||
|
||||
static FriendsDialog *instance = NULL;
|
||||
|
||||
/** Constructor */
|
||||
FriendsDialog::FriendsDialog(QWidget *parent)
|
||||
: RsAutoUpdatePage(1500,parent)
|
||||
@ -75,6 +77,10 @@ FriendsDialog::FriendsDialog(QWidget *parent)
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
if (instance == NULL) {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
last_status_send_time = 0 ;
|
||||
|
||||
connect( ui.mypersonalstatuslabel, SIGNAL(clicked()), SLOT(statusmessage()));
|
||||
@ -87,18 +93,20 @@ FriendsDialog::FriendsDialog(QWidget *parent)
|
||||
ui.avatar->setFrameType(AvatarWidget::STATUS_FRAME);
|
||||
ui.avatar->setOwnId();
|
||||
|
||||
chatLobbyWidget = new ChatLobbyWidget();
|
||||
QObject::connect(chatLobbyWidget, SIGNAL(infoChanged()), this, SLOT(lobbyInfoChanged()));
|
||||
chatlobbyTabIndex = ui.peertabWidget->addTab(chatLobbyWidget, tr("Chat lobbies"));
|
||||
ui.peertabWidget->setTabPosition(QTabWidget::North);
|
||||
ui.peertabWidget->addTab(new ProfileWidget(), tr("Profile"));
|
||||
ui.tabWidget->setTabPosition(QTabWidget::North);
|
||||
ui.tabWidget->addTab(new ChatLobbyWidget(), tr("Chat lobbies"));
|
||||
ui.tabWidget->addTab(new ProfileWidget(), tr("Profile"));
|
||||
NewsFeed *newsFeed = new NewsFeed();
|
||||
newsFeedTabIndex = ui.peertabWidget->addTab(newsFeed, tr("News Feed"));
|
||||
ui.peertabWidget->tabBar()->setIconSize(QSize(10, 10));
|
||||
newsFeedTabIndex = ui.tabWidget->addTab(newsFeed, tr("News Feed"));
|
||||
|
||||
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 */
|
||||
newsFeedTabColor = ui.peertabWidget->tabBar()->tabTextColor(newsFeedTabIndex);
|
||||
newsFeedText = ui.peertabWidget->tabBar()->tabText(newsFeedTabIndex);
|
||||
newsFeedTabColor = ui.tabWidget->tabBar()->tabTextColor(newsFeedTabIndex);
|
||||
newsFeedText = ui.tabWidget->tabBar()->tabText(newsFeedTabIndex);
|
||||
|
||||
connect(newsFeed, SIGNAL(newsFeedChanged(int)), this, SLOT(newsFeedChanged(int)));
|
||||
|
||||
@ -206,6 +214,10 @@ FriendsDialog::~FriendsDialog ()
|
||||
{
|
||||
// save settings
|
||||
processSettings(false);
|
||||
|
||||
if (this == instance) {
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void FriendsDialog::processSettings(bool bLoad)
|
||||
@ -810,28 +822,23 @@ void FriendsDialog::on_actionAdd_Group_activated()
|
||||
void FriendsDialog::newsFeedChanged(int count)
|
||||
{
|
||||
if (count) {
|
||||
ui.peertabWidget->tabBar()->setTabText(newsFeedTabIndex, QString("%1 (%2)").arg(newsFeedText).arg(count));
|
||||
ui.peertabWidget->tabBar()->setTabTextColor(newsFeedTabIndex, Qt::blue);
|
||||
ui.peertabWidget->tabBar()->setTabIcon(newsFeedTabIndex, QIcon(IMAGE_NEWSFEED_NEW));
|
||||
ui.tabWidget->tabBar()->setTabText(newsFeedTabIndex, QString("%1 (%2)").arg(newsFeedText).arg(count));
|
||||
ui.tabWidget->tabBar()->setTabTextColor(newsFeedTabIndex, Qt::blue);
|
||||
ui.tabWidget->tabBar()->setTabIcon(newsFeedTabIndex, QIcon(IMAGE_NEWSFEED_NEW));
|
||||
} else {
|
||||
ui.peertabWidget->tabBar()->setTabText(newsFeedTabIndex, newsFeedText);
|
||||
ui.peertabWidget->tabBar()->setTabTextColor(newsFeedTabIndex, newsFeedTabColor);
|
||||
ui.peertabWidget->tabBar()->setTabIcon(newsFeedTabIndex, QIcon(IMAGE_NEWSFEED));
|
||||
ui.tabWidget->tabBar()->setTabText(newsFeedTabIndex, newsFeedText);
|
||||
ui.tabWidget->tabBar()->setTabTextColor(newsFeedTabIndex, newsFeedTabColor);
|
||||
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()
|
||||
{
|
||||
std::list<std::string> friends;
|
||||
CreateLobbyDialog(friends).exec();
|
||||
}
|
||||
|
||||
/*static*/ ChatTabWidget *FriendsDialog::getTabWidget()
|
||||
{
|
||||
return instance ? instance->ui.tabWidget : NULL;
|
||||
}
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "mainpage.h"
|
||||
|
||||
|
||||
#ifndef MINIMAL_RSGUI
|
||||
#include "ui_FriendsDialog.h"
|
||||
|
||||
@ -35,8 +34,7 @@ class QFont;
|
||||
class QAction;
|
||||
class QTextEdit;
|
||||
class QTextCharFormat;
|
||||
class ChatDialog;
|
||||
class ChatLobbyWidget;
|
||||
class ChatTabWidget;
|
||||
|
||||
class FriendsDialog : public RsAutoUpdatePage
|
||||
{
|
||||
@ -50,6 +48,8 @@ public:
|
||||
|
||||
virtual void updateDisplay() ; // overloaded from RsAutoUpdatePage
|
||||
|
||||
static ChatTabWidget *getTabWidget();
|
||||
|
||||
public slots:
|
||||
|
||||
void publicChatChanged(int type);
|
||||
@ -112,8 +112,6 @@ private slots:
|
||||
|
||||
void newsFeedChanged(int count);
|
||||
|
||||
void lobbyInfoChanged();
|
||||
|
||||
void createChatLobby();
|
||||
|
||||
signals:
|
||||
@ -142,9 +140,6 @@ private:
|
||||
QColor newsFeedTabColor;
|
||||
QString newsFeedText;
|
||||
|
||||
ChatLobbyWidget *chatLobbyWidget;
|
||||
int chatlobbyTabIndex;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::FriendsDialog ui;
|
||||
};
|
||||
|
@ -810,10 +810,13 @@ p, li { white-space: pre-wrap; }
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="RSTabWidget" name="peertabWidget">
|
||||
<widget class="ChatTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Group Chat</string>
|
||||
@ -1441,6 +1444,12 @@ background: white;}</string>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ChatTabWidget</class>
|
||||
<extends>QTabWidget</extends>
|
||||
<header location="global">gui/chat/ChatTabWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AvatarWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
@ -1453,12 +1462,6 @@ background: white;}</string>
|
||||
<header location="global">gui/common/HashBox.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>RSTabWidget</class>
|
||||
<extends>QTabWidget</extends>
|
||||
<header>gui/common/RSTabWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>FriendList</class>
|
||||
<extends>QWidget</extends>
|
||||
|
@ -300,11 +300,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
ui.messagestreeView->installEventFilter(this);
|
||||
|
||||
// remove close button of the the first tab
|
||||
QTabBar::ButtonPosition buttonPosition = (QTabBar::ButtonPosition) ui.tabWidget->tabBar()->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, 0);
|
||||
QWidget *tabButton = ui.tabWidget->tabBar()->tabButton(0, buttonPosition);
|
||||
if (tabButton) {
|
||||
tabButton->hide();
|
||||
}
|
||||
ui.tabWidget->hideCloseButton(0);
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
|
@ -23,9 +23,10 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "ChatLobbyDialog.h"
|
||||
#include "gui/ChatLobbyWidget.h"
|
||||
#include "ChatTabWidget.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/settings/RsharePeerSettings.h"
|
||||
#include "gui/FriendsDialog.h"
|
||||
|
||||
#include <retroshare/rsnotify.h>
|
||||
|
||||
@ -55,7 +56,7 @@ void ChatLobbyDialog::init(const std::string &peerId, const QString &title)
|
||||
showParticipantsFrame(PeerSettings->getShowParticipantsFrame(peerId));
|
||||
|
||||
// add to window
|
||||
ChatTabWidget *tabWidget = ChatLobbyWidget::getTabWidget();
|
||||
ChatTabWidget *tabWidget = FriendsDialog::getTabWidget();
|
||||
if (tabWidget) {
|
||||
tabWidget->addDialog(this);
|
||||
}
|
||||
@ -174,7 +175,7 @@ bool ChatLobbyDialog::canClose()
|
||||
void ChatLobbyDialog::showDialog(uint chatflags)
|
||||
{
|
||||
if (chatflags & RS_CHAT_FOCUS) {
|
||||
ChatTabWidget *tabWidget = ChatLobbyWidget::getTabWidget();
|
||||
ChatTabWidget *tabWidget = FriendsDialog::getTabWidget();
|
||||
if (tabWidget) {
|
||||
tabWidget->setCurrentWidget(this);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define IMAGE_CHAT ":/images/chat.png"
|
||||
|
||||
ChatTabWidget::ChatTabWidget(QWidget *parent) :
|
||||
QTabWidget(parent),
|
||||
RSTabWidget(parent),
|
||||
ui(new Ui::ChatTabWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -23,7 +23,7 @@
|
||||
#ifndef CHATTABWIDGET_H
|
||||
#define CHATTABWIDGET_H
|
||||
|
||||
#include <QTabWidget>
|
||||
#include "gui/common/RSTabWidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class ChatTabWidget;
|
||||
@ -31,7 +31,7 @@ class ChatTabWidget;
|
||||
|
||||
class ChatDialog;
|
||||
|
||||
class ChatTabWidget : public QTabWidget
|
||||
class ChatTabWidget : public RSTabWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -19,6 +19,9 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QTabBar>
|
||||
#include <QStyle>
|
||||
|
||||
#include "RSTabWidget.h"
|
||||
|
||||
RSTabWidget::RSTabWidget(QWidget *parent) : QTabWidget(parent)
|
||||
@ -27,5 +30,14 @@ RSTabWidget::RSTabWidget(QWidget *parent) : QTabWidget(parent)
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,12 @@
|
||||
class RSTabWidget : public QTabWidget
|
||||
{
|
||||
public:
|
||||
RSTabWidget(QWidget *parent = 0);
|
||||
RSTabWidget(QWidget *parent = 0);
|
||||
|
||||
void hideCloseButton(int index);
|
||||
|
||||
public:
|
||||
QTabBar *tabBar() const;
|
||||
QTabBar *tabBar() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user