mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -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
@ -81,7 +81,7 @@ p3Forums::p3Forums(uint16_t type, CacheStrapper *cs, CacheTransfer *cft,
|
||||
std::string srcdir, std::string storedir, std::string forumDir)
|
||||
:p3GroupDistrib(type, cs, cft, srcdir, storedir, forumDir,
|
||||
CONFIG_TYPE_FORUMS, FORUM_STOREPERIOD, FORUM_PUBPERIOD),
|
||||
mForumsChanged(false), mForumsDir(forumDir)
|
||||
mForumsDir(forumDir)
|
||||
{
|
||||
|
||||
/* create chanDir */
|
||||
@ -588,8 +588,6 @@ void p3Forums::loadDummyData()
|
||||
fi.lastPost = now - 1234;
|
||||
|
||||
forumId = createForum(fi.forumName, fi.forumDesc, fi.forumFlags);
|
||||
|
||||
mForumsChanged = true;
|
||||
}
|
||||
|
||||
std::list<RsItem* > p3Forums::childSaveList()
|
||||
|
@ -91,15 +91,11 @@ std::string createForumMsg(std::string fId, std::string pId,
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
bool mForumsChanged;
|
||||
std::string mForumsDir;
|
||||
std::list<RsItem *> mSaveList; // store save data
|
||||
|
||||
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
|
||||
return true; // marked as read from the gui itself, so the gui
|
||||
else // can mark it as read.
|
||||
if(changed) {
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
|
@ -307,6 +307,9 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
||||
/* Set focus to the current page */
|
||||
ui.stackPages->currentWidget()->setFocus();
|
||||
|
||||
/* call once */
|
||||
updateMessages();
|
||||
|
||||
idle = new Idle();
|
||||
idle->start();
|
||||
connect(idle, SIGNAL(secondsIdle(int)), this, SLOT(checkAndSetIdle(int)));
|
||||
@ -359,8 +362,7 @@ void MainWindow::createTrayIcon()
|
||||
/** Tray icon Menu **/
|
||||
trayMenu = new QMenu(this);
|
||||
QObject::connect(trayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
||||
toggleVisibilityAction =
|
||||
trayMenu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
|
||||
toggleVisibilityAction = trayMenu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
|
||||
|
||||
QMenu *pStatusMenu = trayMenu->addMenu(tr("Status"));
|
||||
initializeStatusObject(pStatusMenu, true);
|
||||
@ -388,9 +390,13 @@ void MainWindow::createTrayIcon()
|
||||
trayIcon->setContextMenu(trayMenu);
|
||||
trayIcon->setIcon(QIcon(IMAGE_NOONLINE));
|
||||
|
||||
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this,
|
||||
SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
|
||||
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
|
||||
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()
|
||||
@ -412,11 +418,34 @@ void MainWindow::displaySystrayMsg(const QString& title,const QString& msg)
|
||||
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()
|
||||
{
|
||||
// This call is essential to remove locks due to QEventLoop re-entrance while asking gpg passwds. Dont' remove it!
|
||||
if(RsAutoUpdatePage::eventsLocked())
|
||||
return ;
|
||||
return;
|
||||
|
||||
unsigned int nFriendCount = 0;
|
||||
unsigned int nOnlineCount = 0;
|
||||
@ -431,42 +460,21 @@ void MainWindow::updateStatus()
|
||||
if (natstatus)
|
||||
natstatus->getNATStatus();
|
||||
|
||||
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)
|
||||
{
|
||||
trayIcon->setIcon(QIcon(":/images/newmsg.png"));
|
||||
if (newInboxCount > 1) {
|
||||
trayIcon->setToolTip(tr("RetroShare") + "\n" + tr("You have %1 new messages").arg(newInboxCount));
|
||||
} else {
|
||||
trayIcon->setToolTip(tr("RetroShare") + "\n" + tr("You have %1 new message").arg(newInboxCount));
|
||||
}
|
||||
}
|
||||
else if (nOnlineCount == 0)
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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()
|
||||
{
|
||||
if (isVisible())
|
||||
|
@ -141,6 +141,7 @@ public slots:
|
||||
void postModDirectories(bool update_local);
|
||||
void displayDiskSpaceWarning(int loc,int size_limit_mb) ;
|
||||
void checkAndSetIdle(int idleTime);
|
||||
void updateMessages();
|
||||
|
||||
protected:
|
||||
/** Default Constructor */
|
||||
@ -158,7 +159,7 @@ private slots:
|
||||
|
||||
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
|
||||
void toggleVisibilitycontextmenu();
|
||||
|
||||
void trayIconMessagesClicked(QSystemTrayIcon::ActivationReason e);
|
||||
|
||||
/** Toolbar fns. */
|
||||
void addFriend();
|
||||
@ -220,6 +221,7 @@ private:
|
||||
void loadStyleSheet(const QString &sheetName);
|
||||
|
||||
QSystemTrayIcon *trayIcon;
|
||||
QSystemTrayIcon *trayIconMessages;
|
||||
QAction *toggleVisibilityAction, *toolAct;
|
||||
QMenu *trayMenu;
|
||||
|
||||
|
@ -1662,6 +1662,8 @@ void MessagesDialog::updateCurrentMessage()
|
||||
|
||||
void MessagesDialog::setMsgAsReadUnread(const QList<int> &Rows, bool bRead)
|
||||
{
|
||||
LockUpdate Lock (this, false);
|
||||
|
||||
for (int nRow = 0; nRow < Rows.size(); nRow++) {
|
||||
QStandardItem* item[COLUMN_COUNT];
|
||||
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();
|
||||
|
||||
m_pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
||||
if (bRead) {
|
||||
// set as read in config
|
||||
m_pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
||||
m_pConfig->setValue(mid, false);
|
||||
m_pConfig->endGroup();
|
||||
// set message to read
|
||||
rsMsgs->MessageRead(mid.toStdString());
|
||||
} else {
|
||||
// set as unread in config
|
||||
m_pConfig->beginGroup(CONFIG_SECTION_UNREAD);
|
||||
m_pConfig->setValue(mid, true);
|
||||
}
|
||||
m_pConfig->endGroup();
|
||||
}
|
||||
|
||||
InitIconAndFont(m_pConfig, item, 0);
|
||||
}
|
||||
|
||||
|
||||
// LockUpdate
|
||||
}
|
||||
|
||||
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(neighborsChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ;
|
||||
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(peerHasNewCustomStateString(const QString&)),w->peersDialog,SLOT(updatePeersCustomStateString(const QString&)));
|
||||
|
Loading…
Reference in New Issue
Block a user