mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 08:29:26 -05:00
Added user notify for chat lobbies.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7752 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2bacb70914
commit
212e5c28f2
@ -10,6 +10,7 @@
|
||||
#include "common/RSTreeWidgetItem.h"
|
||||
#include "notifyqt.h"
|
||||
#include "chat/ChatLobbyDialog.h"
|
||||
#include "chat/ChatLobbyUserNotify.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/QtVersion.h"
|
||||
#include <gui/settings/rsharesettings.h>
|
||||
@ -186,6 +187,16 @@ ChatLobbyWidget::~ChatLobbyWidget()
|
||||
}
|
||||
}
|
||||
|
||||
UserNotify *ChatLobbyWidget::getUserNotify(QObject *parent)
|
||||
{
|
||||
ChatLobbyUserNotify *notify = new ChatLobbyUserNotify(parent);
|
||||
connect(this, SIGNAL(unreadCountChanged(uint)), notify, SLOT(unreadCountChanged(uint)));
|
||||
|
||||
notify->unreadCountChanged(unreadCount());
|
||||
|
||||
return notify;
|
||||
}
|
||||
|
||||
void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint)
|
||||
{
|
||||
std::cerr << "Creating customPopupMennu" << std::endl;
|
||||
@ -286,6 +297,7 @@ void ChatLobbyWidget::addChatPage(ChatLobbyDialog *d)
|
||||
_lobby_infos[id].dialog = d ;
|
||||
_lobby_infos[id].default_icon = QIcon() ;
|
||||
_lobby_infos[id].last_typing_event = time(NULL) ;
|
||||
_lobby_infos[id].unread_count = 0;
|
||||
|
||||
std::list<ChatLobbyInfo> lobbies;
|
||||
rsMsgs->getChatLobbyList(lobbies);
|
||||
@ -736,6 +748,7 @@ void ChatLobbyWidget::unsubscribeChatLobby(ChatLobbyId id)
|
||||
{
|
||||
ui.stackedWidget->removeWidget(it->second.dialog) ;
|
||||
_lobby_infos.erase(it) ;
|
||||
emit unreadCountChanged(unreadCount());
|
||||
}
|
||||
|
||||
// Unsubscribe the chat lobby
|
||||
@ -778,7 +791,10 @@ void ChatLobbyWidget::updateCurrentLobby()
|
||||
int iPrivacyLevel= item->parent()->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt();
|
||||
QIcon icon = (iPrivacyLevel==RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
|
||||
_lobby_infos[id].default_icon = icon ;
|
||||
_lobby_infos[id].unread_count = 0;
|
||||
item->setIcon(COLUMN_NAME, icon) ;
|
||||
|
||||
emit unreadCountChanged(unreadCount());
|
||||
}
|
||||
}
|
||||
|
||||
@ -796,6 +812,9 @@ void ChatLobbyWidget::updateMessageChanged(ChatLobbyId id)
|
||||
return ;
|
||||
|
||||
_lobby_infos[id].default_icon = QIcon(IMAGE_MESSAGE) ;
|
||||
++_lobby_infos[id].unread_count;
|
||||
|
||||
emit unreadCountChanged(unreadCount());
|
||||
|
||||
QTreeWidgetItem *item = getTreeWidgetItem(id) ;
|
||||
|
||||
@ -953,3 +972,13 @@ int ChatLobbyWidget::getNumColVisible()
|
||||
return iNumColVis;
|
||||
}
|
||||
|
||||
uint ChatLobbyWidget::unreadCount()
|
||||
{
|
||||
uint count = 0;
|
||||
|
||||
for (std::map<ChatLobbyId,ChatLobbyInfoStruct>::iterator it = _lobby_infos.begin(); it != _lobby_infos.end(); ++it) {
|
||||
count += it->second.unread_count;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ struct ChatLobbyInfoStruct
|
||||
QIcon default_icon ;
|
||||
ChatLobbyDialog *dialog ;
|
||||
time_t last_typing_event ;
|
||||
uint unread_count;
|
||||
};
|
||||
|
||||
class ChatLobbyWidget : public RsAutoUpdatePage
|
||||
@ -34,11 +35,18 @@ public:
|
||||
virtual QString pageName() const { return tr("Chat Lobbies") ; } //MainPage
|
||||
virtual QString helpText() const { return ""; } //MainPage
|
||||
|
||||
virtual UserNotify *getUserNotify(QObject *parent);
|
||||
|
||||
virtual void updateDisplay();
|
||||
|
||||
void setCurrentChatPage(ChatLobbyDialog *) ; // used by ChatLobbyDialog to raise.
|
||||
void addChatPage(ChatLobbyDialog *) ;
|
||||
|
||||
uint unreadCount();
|
||||
|
||||
signals:
|
||||
void unreadCountChanged(uint unreadCount);
|
||||
|
||||
protected slots:
|
||||
void lobbyChanged();
|
||||
void lobbyTreeWidgetCustomPopupMenu(QPoint);
|
||||
|
64
retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp
Normal file
64
retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include "ChatLobbyUserNotify.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/MainWindow.h"
|
||||
|
||||
ChatLobbyUserNotify::ChatLobbyUserNotify(QObject *parent) :
|
||||
UserNotify(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool ChatLobbyUserNotify::hasSetting(QString *name, QString *group)
|
||||
{
|
||||
if (name) *name = tr("Chat Lobbies");
|
||||
if (group) *group = "ChatLobby";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QIcon ChatLobbyUserNotify::getIcon()
|
||||
{
|
||||
return QIcon(":/images/chat_32.png");
|
||||
}
|
||||
|
||||
QIcon ChatLobbyUserNotify::getMainIcon(bool hasNew)
|
||||
{
|
||||
return hasNew ? QIcon(":/images/chat_red24.png") : QIcon(":/images/chat_32.png");
|
||||
}
|
||||
|
||||
unsigned int ChatLobbyUserNotify::getNewCount()
|
||||
{
|
||||
return mUnreadCount;
|
||||
}
|
||||
|
||||
void ChatLobbyUserNotify::iconClicked()
|
||||
{
|
||||
MainWindow::showWindow(MainWindow::ChatLobby);
|
||||
}
|
||||
|
||||
void ChatLobbyUserNotify::unreadCountChanged(unsigned int unreadCount)
|
||||
{
|
||||
mUnreadCount = unreadCount;
|
||||
|
||||
updateIcon();
|
||||
}
|
49
retroshare-gui/src/gui/chat/ChatLobbyUserNotify.h
Normal file
49
retroshare-gui/src/gui/chat/ChatLobbyUserNotify.h
Normal file
@ -0,0 +1,49 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef CHATLOBBYUSERNOTIFY_H
|
||||
#define CHATLOBBYUSERNOTIFY_H
|
||||
|
||||
#include "gui/common/UserNotify.h"
|
||||
|
||||
class ChatLobbyUserNotify : public UserNotify
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChatLobbyUserNotify(QObject *parent = 0);
|
||||
|
||||
virtual bool hasSetting(QString *name, QString *group);
|
||||
|
||||
public slots:
|
||||
void unreadCountChanged(uint unreadCount);
|
||||
|
||||
private:
|
||||
virtual QIcon getIcon();
|
||||
virtual QIcon getMainIcon(bool hasNew);
|
||||
virtual unsigned int getNewCount();
|
||||
virtual void iconClicked();
|
||||
|
||||
private:
|
||||
uint mUnreadCount;
|
||||
};
|
||||
|
||||
#endif // CHATLOBBYUSERNOTIFY_H
|
@ -392,6 +392,7 @@ HEADERS += rshare.h \
|
||||
gui/chat/CreateLobbyDialog.h \
|
||||
gui/chat/ChatStyle.h \
|
||||
gui/chat/ChatUserNotify.h \
|
||||
gui/chat/ChatLobbyUserNotify.h \
|
||||
gui/connect/ConfCertDialog.h \
|
||||
gui/msgs/MessageComposer.h \
|
||||
gui/msgs/MessageWindow.h \
|
||||
@ -724,6 +725,7 @@ SOURCES += main.cpp \
|
||||
gui/chat/CreateLobbyDialog.cpp \
|
||||
gui/chat/ChatStyle.cpp \
|
||||
gui/chat/ChatUserNotify.cpp \
|
||||
gui/chat/ChatLobbyUserNotify.cpp \
|
||||
gui/connect/ConfCertDialog.cpp \
|
||||
gui/msgs/MessageComposer.cpp \
|
||||
gui/msgs/MessageWidget.cpp \
|
||||
|
Loading…
Reference in New Issue
Block a user