mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-23 16:21:29 -04:00
Moved notify of new messages in MainWindow from QTimer to signal messagesChanged.
Show own tray icon for new messages. Removed unused member p3Forums::mForumsChanged. The message service send a notify on p3MsgService::markMsgIdRead too. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3353 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
86ae9983d1
commit
32afd370bb
7 changed files with 88 additions and 67 deletions
|
@ -81,7 +81,7 @@ p3Forums::p3Forums(uint16_t type, CacheStrapper *cs, CacheTransfer *cft,
|
||||||
std::string srcdir, std::string storedir, std::string forumDir)
|
std::string srcdir, std::string storedir, std::string forumDir)
|
||||||
:p3GroupDistrib(type, cs, cft, srcdir, storedir, forumDir,
|
:p3GroupDistrib(type, cs, cft, srcdir, storedir, forumDir,
|
||||||
CONFIG_TYPE_FORUMS, FORUM_STOREPERIOD, FORUM_PUBPERIOD),
|
CONFIG_TYPE_FORUMS, FORUM_STOREPERIOD, FORUM_PUBPERIOD),
|
||||||
mForumsChanged(false), mForumsDir(forumDir)
|
mForumsDir(forumDir)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* create chanDir */
|
/* create chanDir */
|
||||||
|
@ -588,8 +588,6 @@ void p3Forums::loadDummyData()
|
||||||
fi.lastPost = now - 1234;
|
fi.lastPost = now - 1234;
|
||||||
|
|
||||||
forumId = createForum(fi.forumName, fi.forumDesc, fi.forumFlags);
|
forumId = createForum(fi.forumName, fi.forumDesc, fi.forumFlags);
|
||||||
|
|
||||||
mForumsChanged = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<RsItem* > p3Forums::childSaveList()
|
std::list<RsItem* > p3Forums::childSaveList()
|
||||||
|
|
|
@ -91,15 +91,11 @@ std::string createForumMsg(std::string fId, std::string pId,
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool mForumsChanged;
|
|
||||||
std::string mForumsDir;
|
std::string mForumsDir;
|
||||||
std::list<RsItem *> mSaveList; // store save data
|
std::list<RsItem *> mSaveList; // store save data
|
||||||
|
|
||||||
std::list<RsForumReadStatus *> mReadStatus;
|
std::list<RsForumReadStatus *> mReadStatus;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -615,10 +615,12 @@ bool p3MsgService::markMsgIdRead(std::string mid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(changed) // no need to notify, because the msg is always
|
if(changed) {
|
||||||
return true; // marked as read from the gui itself, so the gui
|
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
||||||
else // can mark it as read.
|
return true;
|
||||||
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
|
|
@ -307,6 +307,9 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
||||||
/* Set focus to the current page */
|
/* Set focus to the current page */
|
||||||
ui.stackPages->currentWidget()->setFocus();
|
ui.stackPages->currentWidget()->setFocus();
|
||||||
|
|
||||||
|
/* call once */
|
||||||
|
updateMessages();
|
||||||
|
|
||||||
idle = new Idle();
|
idle = new Idle();
|
||||||
idle->start();
|
idle->start();
|
||||||
connect(idle, SIGNAL(secondsIdle(int)), this, SLOT(checkAndSetIdle(int)));
|
connect(idle, SIGNAL(secondsIdle(int)), this, SLOT(checkAndSetIdle(int)));
|
||||||
|
@ -359,8 +362,7 @@ void MainWindow::createTrayIcon()
|
||||||
/** Tray icon Menu **/
|
/** Tray icon Menu **/
|
||||||
trayMenu = new QMenu(this);
|
trayMenu = new QMenu(this);
|
||||||
QObject::connect(trayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
QObject::connect(trayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
||||||
toggleVisibilityAction =
|
toggleVisibilityAction = trayMenu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
|
||||||
trayMenu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
|
|
||||||
|
|
||||||
QMenu *pStatusMenu = trayMenu->addMenu(tr("Status"));
|
QMenu *pStatusMenu = trayMenu->addMenu(tr("Status"));
|
||||||
initializeStatusObject(pStatusMenu, true);
|
initializeStatusObject(pStatusMenu, true);
|
||||||
|
@ -388,9 +390,13 @@ void MainWindow::createTrayIcon()
|
||||||
trayIcon->setContextMenu(trayMenu);
|
trayIcon->setContextMenu(trayMenu);
|
||||||
trayIcon->setIcon(QIcon(IMAGE_NOONLINE));
|
trayIcon->setIcon(QIcon(IMAGE_NOONLINE));
|
||||||
|
|
||||||
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this,
|
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
|
||||||
SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
|
|
||||||
trayIcon->show();
|
trayIcon->show();
|
||||||
|
|
||||||
|
// Create the tray icon for messages
|
||||||
|
trayIconMessages = new QSystemTrayIcon(this);
|
||||||
|
trayIconMessages->setIcon(QIcon(":/images/newmsg.png"));
|
||||||
|
connect(trayIconMessages, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconMessagesClicked(QSystemTrayIcon::ActivationReason)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ void MainWindow::installGroupChatNotifier()
|
/*static*/ void MainWindow::installGroupChatNotifier()
|
||||||
|
@ -412,62 +418,64 @@ void MainWindow::displaySystrayMsg(const QString& title,const QString& msg)
|
||||||
trayIcon->showMessage(title, msg, QSystemTrayIcon::Information, 3000);
|
trayIcon->showMessage(title, msg, QSystemTrayIcon::Information, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateMessages()
|
||||||
|
{
|
||||||
|
unsigned int newInboxCount = 0;
|
||||||
|
rsMsgs->getMessageCount (NULL, &newInboxCount, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
if(newInboxCount) {
|
||||||
|
messageAction->setIcon(QIcon(QPixmap(":/images/messages_new.png"))) ;
|
||||||
|
} else {
|
||||||
|
messageAction->setIcon(QIcon(QPixmap(":/images/evolution.png"))) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newInboxCount) {
|
||||||
|
if (newInboxCount > 1) {
|
||||||
|
trayIconMessages->setToolTip(tr("RetroShare") + "\n" + tr("You have %1 new messages").arg(newInboxCount));
|
||||||
|
} else {
|
||||||
|
trayIconMessages->setToolTip(tr("RetroShare") + "\n" + tr("You have %1 new message").arg(newInboxCount));
|
||||||
|
}
|
||||||
|
trayIconMessages->show();
|
||||||
|
} else {
|
||||||
|
trayIconMessages->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::updateStatus()
|
void MainWindow::updateStatus()
|
||||||
{
|
{
|
||||||
// This call is essential to remove locks due to QEventLoop re-entrance while asking gpg passwds. Dont' remove it!
|
// This call is essential to remove locks due to QEventLoop re-entrance while asking gpg passwds. Dont' remove it!
|
||||||
if(RsAutoUpdatePage::eventsLocked())
|
if(RsAutoUpdatePage::eventsLocked())
|
||||||
return ;
|
return;
|
||||||
|
|
||||||
unsigned int nFriendCount = 0;
|
unsigned int nFriendCount = 0;
|
||||||
unsigned int nOnlineCount = 0;
|
unsigned int nOnlineCount = 0;
|
||||||
rsPeers->getPeerCount (&nFriendCount, &nOnlineCount);
|
rsPeers->getPeerCount (&nFriendCount, &nOnlineCount);
|
||||||
|
|
||||||
if (ratesstatus)
|
if (ratesstatus)
|
||||||
ratesstatus->getRatesStatus();
|
ratesstatus->getRatesStatus();
|
||||||
|
|
||||||
if (peerstatus)
|
if (peerstatus)
|
||||||
peerstatus->getPeerStatus(nFriendCount, nOnlineCount);
|
peerstatus->getPeerStatus(nFriendCount, nOnlineCount);
|
||||||
|
|
||||||
if (natstatus)
|
if (natstatus)
|
||||||
natstatus->getNATStatus();
|
natstatus->getNATStatus();
|
||||||
|
|
||||||
unsigned int newInboxCount = 0;
|
if (nOnlineCount == 0)
|
||||||
rsMsgs->getMessageCount (NULL, &newInboxCount, NULL, NULL, NULL, NULL);
|
{
|
||||||
|
trayIcon->setIcon(QIcon(IMAGE_NOONLINE));
|
||||||
if(newInboxCount)
|
}
|
||||||
messageAction->setIcon(QIcon(QPixmap(":/images/messages_new.png"))) ;
|
else if (nOnlineCount < 2)
|
||||||
else
|
{
|
||||||
messageAction->setIcon(QIcon(QPixmap(":/images/evolution.png"))) ;
|
trayIcon->setIcon(QIcon(IMAGE_ONEONLINE));
|
||||||
|
}
|
||||||
if(newInboxCount)
|
else if (nOnlineCount < 3)
|
||||||
{
|
{
|
||||||
trayIcon->setIcon(QIcon(":/images/newmsg.png"));
|
trayIcon->setIcon(QIcon(IMAGE_TWOONLINE));
|
||||||
if (newInboxCount > 1) {
|
}
|
||||||
trayIcon->setToolTip(tr("RetroShare") + "\n" + tr("You have %1 new messages").arg(newInboxCount));
|
else
|
||||||
} else {
|
{
|
||||||
trayIcon->setToolTip(tr("RetroShare") + "\n" + tr("You have %1 new message").arg(newInboxCount));
|
trayIcon->setIcon(QIcon(IMAGE_RETROSHARE));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (nOnlineCount == 0)
|
|
||||||
{
|
|
||||||
trayIcon->setIcon(QIcon(IMAGE_NOONLINE));
|
|
||||||
trayIcon->setToolTip(tr("RetroShare"));
|
|
||||||
}
|
|
||||||
else if (nOnlineCount < 2)
|
|
||||||
{
|
|
||||||
trayIcon->setIcon(QIcon(IMAGE_ONEONLINE));
|
|
||||||
trayIcon->setToolTip(tr("RetroShare"));
|
|
||||||
}
|
|
||||||
else if (nOnlineCount < 3)
|
|
||||||
{
|
|
||||||
trayIcon->setIcon(QIcon(IMAGE_TWOONLINE));
|
|
||||||
trayIcon->setToolTip(tr("RetroShare"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
trayIcon->setIcon(QIcon(IMAGE_RETROSHARE));
|
|
||||||
trayIcon->setToolTip(tr("RetroShare"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateHashingInfo(const QString& s)
|
void MainWindow::updateHashingInfo(const QString& s)
|
||||||
|
@ -759,6 +767,13 @@ void MainWindow::toggleVisibility(QSystemTrayIcon::ActivationReason e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::trayIconMessagesClicked(QSystemTrayIcon::ActivationReason e)
|
||||||
|
{
|
||||||
|
if(e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick) {
|
||||||
|
showMess();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::toggleVisibilitycontextmenu()
|
void MainWindow::toggleVisibilitycontextmenu()
|
||||||
{
|
{
|
||||||
if (isVisible())
|
if (isVisible())
|
||||||
|
|
|
@ -139,8 +139,9 @@ public slots:
|
||||||
void updateHashingInfo(const QString&) ;
|
void updateHashingInfo(const QString&) ;
|
||||||
void displayErrorMessage(int,int,const QString&) ;
|
void displayErrorMessage(int,int,const QString&) ;
|
||||||
void postModDirectories(bool update_local);
|
void postModDirectories(bool update_local);
|
||||||
void displayDiskSpaceWarning(int loc,int size_limit_mb) ;
|
void displayDiskSpaceWarning(int loc,int size_limit_mb) ;
|
||||||
void checkAndSetIdle(int idleTime);
|
void checkAndSetIdle(int idleTime);
|
||||||
|
void updateMessages();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Default Constructor */
|
/** Default Constructor */
|
||||||
|
@ -158,7 +159,7 @@ private slots:
|
||||||
|
|
||||||
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
|
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
|
||||||
void toggleVisibilitycontextmenu();
|
void toggleVisibilitycontextmenu();
|
||||||
|
void trayIconMessagesClicked(QSystemTrayIcon::ActivationReason e);
|
||||||
|
|
||||||
/** Toolbar fns. */
|
/** Toolbar fns. */
|
||||||
void addFriend();
|
void addFriend();
|
||||||
|
@ -220,6 +221,7 @@ private:
|
||||||
void loadStyleSheet(const QString &sheetName);
|
void loadStyleSheet(const QString &sheetName);
|
||||||
|
|
||||||
QSystemTrayIcon *trayIcon;
|
QSystemTrayIcon *trayIcon;
|
||||||
|
QSystemTrayIcon *trayIconMessages;
|
||||||
QAction *toggleVisibilityAction, *toolAct;
|
QAction *toggleVisibilityAction, *toolAct;
|
||||||
QMenu *trayMenu;
|
QMenu *trayMenu;
|
||||||
|
|
||||||
|
|
|
@ -1662,6 +1662,8 @@ void MessagesDialog::updateCurrentMessage()
|
||||||
|
|
||||||
void MessagesDialog::setMsgAsReadUnread(const QList<int> &Rows, bool bRead)
|
void MessagesDialog::setMsgAsReadUnread(const QList<int> &Rows, bool bRead)
|
||||||
{
|
{
|
||||||
|
LockUpdate Lock (this, false);
|
||||||
|
|
||||||
for (int nRow = 0; nRow < Rows.size(); nRow++) {
|
for (int nRow = 0; nRow < Rows.size(); nRow++) {
|
||||||
QStandardItem* item[COLUMN_COUNT];
|
QStandardItem* item[COLUMN_COUNT];
|
||||||
for(int nCol = 0; nCol < COLUMN_COUNT; nCol++)
|
for(int nCol = 0; nCol < COLUMN_COUNT; nCol++)
|
||||||
|
@ -1671,20 +1673,25 @@ void MessagesDialog::setMsgAsReadUnread(const QList<int> &Rows, bool bRead)
|
||||||
|
|
||||||
QString mid = item[COLUMN_DATA]->data(ROLE_MSGID).toString();
|
QString mid = item[COLUMN_DATA]->data(ROLE_MSGID).toString();
|
||||||
|
|
||||||
m_pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
|
||||||
if (bRead) {
|
if (bRead) {
|
||||||
// set as read in config
|
// set as read in config
|
||||||
|
m_pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
||||||
m_pConfig->setValue(mid, false);
|
m_pConfig->setValue(mid, false);
|
||||||
|
m_pConfig->endGroup();
|
||||||
// set message to read
|
// set message to read
|
||||||
rsMsgs->MessageRead(mid.toStdString());
|
rsMsgs->MessageRead(mid.toStdString());
|
||||||
} else {
|
} else {
|
||||||
// set as unread in config
|
// set as unread in config
|
||||||
|
m_pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
||||||
m_pConfig->setValue(mid, true);
|
m_pConfig->setValue(mid, true);
|
||||||
|
m_pConfig->endGroup();
|
||||||
}
|
}
|
||||||
m_pConfig->endGroup();
|
|
||||||
|
|
||||||
InitIconAndFont(m_pConfig, item, 0);
|
InitIconAndFont(m_pConfig, item, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// LockUpdate
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesDialog::markAsRead()
|
void MessagesDialog::markAsRead()
|
||||||
|
|
|
@ -177,6 +177,7 @@ int main(int argc, char *argv[])
|
||||||
QObject::connect(notify,SIGNAL(friendsChanged()) ,w->peersDialog ,SLOT(insertPeers() )) ;
|
QObject::connect(notify,SIGNAL(friendsChanged()) ,w->peersDialog ,SLOT(insertPeers() )) ;
|
||||||
QObject::connect(notify,SIGNAL(neighborsChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ;
|
QObject::connect(notify,SIGNAL(neighborsChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ;
|
||||||
QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ;
|
QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ;
|
||||||
|
QObject::connect(notify,SIGNAL(messagesChanged()) ,w ,SLOT(updateMessages() )) ;
|
||||||
|
|
||||||
QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool)));
|
QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool)));
|
||||||
QObject::connect(notify,SIGNAL(peerHasNewCustomStateString(const QString&)),w->peersDialog,SLOT(updatePeersCustomStateString(const QString&)));
|
QObject::connect(notify,SIGNAL(peerHasNewCustomStateString(const QString&)),w->peersDialog,SLOT(updatePeersCustomStateString(const QString&)));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue