mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
- Fixed fill of news feed.
- Added display of feed count in main action. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6454 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0a10092816
commit
766bd9c6ae
@ -153,7 +153,7 @@
|
|||||||
#define IMAGE_ONEONLINE ":/images/rstray1.png"
|
#define IMAGE_ONEONLINE ":/images/rstray1.png"
|
||||||
#define IMAGE_TWOONLINE ":/images/rstray2.png"
|
#define IMAGE_TWOONLINE ":/images/rstray2.png"
|
||||||
#define IMAGE_BLOGS ":/images/kblogger.png"
|
#define IMAGE_BLOGS ":/images/kblogger.png"
|
||||||
#define IMAGE_DHT ":/images/dht16.png"
|
#define IMAGE_DHT ":/images/dht16.png"
|
||||||
#define IMAGE_CHATLOBBY ":/images/user/agt_forum32.png"
|
#define IMAGE_CHATLOBBY ":/images/user/agt_forum32.png"
|
||||||
|
|
||||||
/*static*/ MainWindow *MainWindow::_instance = NULL;
|
/*static*/ MainWindow *MainWindow::_instance = NULL;
|
||||||
@ -242,7 +242,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
|||||||
QAction *action;
|
QAction *action;
|
||||||
|
|
||||||
ui->stackPages->add(newsFeed = new NewsFeed(ui->stackPages),
|
ui->stackPages->add(newsFeed = new NewsFeed(ui->stackPages),
|
||||||
createPageAction(QIcon(IMAGE_NEWSFEED), tr("News feed"), grp));
|
action = createPageAction(QIcon(IMAGE_NEWSFEED), tr("News feed"), grp));
|
||||||
|
notify.push_back(QPair<MainPage*, QAction*>(newsFeed, action));
|
||||||
|
|
||||||
// ui->stackPages->add(networkDialog = new NetworkDialog(ui->stackPages),
|
// ui->stackPages->add(networkDialog = new NetworkDialog(ui->stackPages),
|
||||||
// createPageAction(QIcon(IMAGE_NETWORK2), tr("Network"), grp));
|
// createPageAction(QIcon(IMAGE_NETWORK2), tr("Network"), grp));
|
||||||
|
@ -44,8 +44,8 @@
|
|||||||
#include "feeds/MsgItem.h"
|
#include "feeds/MsgItem.h"
|
||||||
#include "feeds/PeerItem.h"
|
#include "feeds/PeerItem.h"
|
||||||
#include "feeds/ChatMsgItem.h"
|
#include "feeds/ChatMsgItem.h"
|
||||||
|
|
||||||
#include "feeds/SecurityItem.h"
|
#include "feeds/SecurityItem.h"
|
||||||
|
#include "feeds/NewsFeedUserNotify.h"
|
||||||
|
|
||||||
#include "settings/rsharesettings.h"
|
#include "settings/rsharesettings.h"
|
||||||
#include "chat/ChatDialog.h"
|
#include "chat/ChatDialog.h"
|
||||||
@ -76,16 +76,14 @@ NewsFeed::NewsFeed(QWidget *parent)
|
|||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
setUpdateWhenInvisible(true);
|
||||||
|
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(removeAllButton, SIGNAL(clicked()), this, SLOT(removeAll()));
|
connect(removeAllButton, SIGNAL(clicked()), this, SLOT(removeAll()));
|
||||||
connect(feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions()));
|
connect(feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions()));
|
||||||
|
|
||||||
// QTimer *timer = new QTimer(this);
|
|
||||||
// timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateFeed()));
|
|
||||||
// timer->start(1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NewsFeed::~NewsFeed()
|
NewsFeed::~NewsFeed()
|
||||||
@ -95,6 +93,11 @@ NewsFeed::~NewsFeed()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UserNotify *NewsFeed::getUserNotify(QObject *parent)
|
||||||
|
{
|
||||||
|
return new NewsFeedUserNotify(this, parent);
|
||||||
|
}
|
||||||
|
|
||||||
void NewsFeed::updateDisplay()
|
void NewsFeed::updateDisplay()
|
||||||
{
|
{
|
||||||
if (!rsNotify)
|
if (!rsNotify)
|
||||||
|
@ -44,7 +44,9 @@ public:
|
|||||||
/** Default Destructor */
|
/** Default Destructor */
|
||||||
virtual ~NewsFeed();
|
virtual ~NewsFeed();
|
||||||
|
|
||||||
/* FeedHolder Functions (for FeedItem functionality) */
|
virtual UserNotify *getUserNotify(QObject *parent);
|
||||||
|
|
||||||
|
/* FeedHolder Functions (for FeedItem functionality) */
|
||||||
virtual QScrollArea *getScrollArea();
|
virtual QScrollArea *getScrollArea();
|
||||||
virtual void deleteFeedItem(QWidget *item, uint32_t type);
|
virtual void deleteFeedItem(QWidget *item, uint32_t type);
|
||||||
virtual void openChat(std::string peerId);
|
virtual void openChat(std::string peerId);
|
||||||
|
@ -6,6 +6,8 @@ bool RsAutoUpdatePage::_locked = false ;
|
|||||||
RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period, QWidget *parent, Qt::WindowFlags flags)
|
RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period, QWidget *parent, Qt::WindowFlags flags)
|
||||||
: MainPage(parent, flags)
|
: MainPage(parent, flags)
|
||||||
{
|
{
|
||||||
|
mUpdateWhenInvisible = false;
|
||||||
|
|
||||||
_timer = new QTimer ;
|
_timer = new QTimer ;
|
||||||
_timer->setInterval(ms_update_period);
|
_timer->setInterval(ms_update_period);
|
||||||
_timer->setSingleShot(true);
|
_timer->setSingleShot(true);
|
||||||
@ -25,7 +27,7 @@ RsAutoUpdatePage::~RsAutoUpdatePage()
|
|||||||
|
|
||||||
void RsAutoUpdatePage::securedUpdateDisplay()
|
void RsAutoUpdatePage::securedUpdateDisplay()
|
||||||
{
|
{
|
||||||
if(_locked == false && isVisible()) {
|
if(_locked == false && (mUpdateWhenInvisible || isVisible())) {
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
update() ; // Qt flush
|
update() ; // Qt flush
|
||||||
}
|
}
|
||||||
@ -33,8 +35,8 @@ void RsAutoUpdatePage::securedUpdateDisplay()
|
|||||||
|
|
||||||
void RsAutoUpdatePage::showEvent(QShowEvent */*event*/)
|
void RsAutoUpdatePage::showEvent(QShowEvent */*event*/)
|
||||||
{
|
{
|
||||||
//std::cout << "RsAutoUpdatePage::showEvent() In show event !!" << std::endl ;
|
//std::cout << "RsAutoUpdatePage::showEvent() In show event !!" << std::endl ;
|
||||||
if(!_locked)
|
if(!_locked && !mUpdateWhenInvisible)
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
47
retroshare-gui/src/gui/feeds/NewsFeedUserNotify.cpp
Normal file
47
retroshare-gui/src/gui/feeds/NewsFeedUserNotify.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/****************************************************************
|
||||||
|
* RetroShare is distributed under the following license:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 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 "NewsFeedUserNotify.h"
|
||||||
|
#include "gui/NewsFeed.h"
|
||||||
|
|
||||||
|
NewsFeedUserNotify::NewsFeedUserNotify(NewsFeed *newsFeed, QObject *parent) :
|
||||||
|
UserNotify(parent)
|
||||||
|
{
|
||||||
|
mNewFeedCount = 0;
|
||||||
|
|
||||||
|
connect(newsFeed, SIGNAL(newsFeedChanged(int)), this, SLOT(newsFeedChanged(int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewsFeedUserNotify::newsFeedChanged(int count)
|
||||||
|
{
|
||||||
|
mNewFeedCount = count;
|
||||||
|
updateIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon NewsFeedUserNotify::getMainIcon(bool hasNew)
|
||||||
|
{
|
||||||
|
return hasNew ? QIcon(":/images/newsfeed128.png") : QIcon(":/images/newsfeed128.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int NewsFeedUserNotify::getNewCount()
|
||||||
|
{
|
||||||
|
return mNewFeedCount;
|
||||||
|
}
|
47
retroshare-gui/src/gui/feeds/NewsFeedUserNotify.h
Normal file
47
retroshare-gui/src/gui/feeds/NewsFeedUserNotify.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/****************************************************************
|
||||||
|
* RetroShare is distributed under the following license:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 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 NEWSFEEDUSERNOTIFY_H
|
||||||
|
#define NEWSFEEDUSERNOTIFY_H
|
||||||
|
|
||||||
|
#include "gui/common/UserNotify.h"
|
||||||
|
|
||||||
|
class NewsFeed;
|
||||||
|
|
||||||
|
class NewsFeedUserNotify : public UserNotify
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
NewsFeedUserNotify(NewsFeed *newsFeed, QObject *parent = 0);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void newsFeedChanged(int count);
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual QIcon getMainIcon(bool hasNew);
|
||||||
|
virtual unsigned int getNewCount();
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned int mNewFeedCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NEWSFEEDUSERNOTIFY_H
|
@ -456,6 +456,7 @@ HEADERS += rshare.h \
|
|||||||
gui/feeds/SubFileItem.h \
|
gui/feeds/SubFileItem.h \
|
||||||
gui/feeds/AttachFileItem.h \
|
gui/feeds/AttachFileItem.h \
|
||||||
gui/feeds/SecurityItem.h \
|
gui/feeds/SecurityItem.h \
|
||||||
|
gui/feeds/NewsFeedUserNotify.h \
|
||||||
gui/connect/ConnectFriendWizard.h \
|
gui/connect/ConnectFriendWizard.h \
|
||||||
gui/groups/CreateGroup.h \
|
gui/groups/CreateGroup.h \
|
||||||
gui/dht/DhtWindow.h \
|
gui/dht/DhtWindow.h \
|
||||||
@ -757,6 +758,7 @@ SOURCES += main.cpp \
|
|||||||
gui/feeds/SubFileItem.cpp \
|
gui/feeds/SubFileItem.cpp \
|
||||||
gui/feeds/AttachFileItem.cpp \
|
gui/feeds/AttachFileItem.cpp \
|
||||||
gui/feeds/SecurityItem.cpp \
|
gui/feeds/SecurityItem.cpp \
|
||||||
|
gui/feeds/NewsFeedUserNotify.cpp \
|
||||||
gui/connect/ConnectFriendWizard.cpp \
|
gui/connect/ConnectFriendWizard.cpp \
|
||||||
gui/groups/CreateGroup.cpp \
|
gui/groups/CreateGroup.cpp \
|
||||||
gui/dht/DhtWindow.cpp \
|
gui/dht/DhtWindow.cpp \
|
||||||
|
@ -25,6 +25,8 @@ class RsAutoUpdatePage: public MainPage
|
|||||||
static void unlockAllEvents() ;
|
static void unlockAllEvents() ;
|
||||||
static bool eventsLocked() ;
|
static bool eventsLocked() ;
|
||||||
|
|
||||||
|
void setUpdateWhenInvisible(bool update) { mUpdateWhenInvisible = update; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// This method updates the widget only if not locked, and if visible.
|
// This method updates the widget only if not locked, and if visible.
|
||||||
// This is *the* method to call when on callbacks etc, to avoid locks due
|
// This is *the* method to call when on callbacks etc, to avoid locks due
|
||||||
@ -45,6 +47,7 @@ class RsAutoUpdatePage: public MainPage
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer *_timer ;
|
QTimer *_timer ;
|
||||||
|
bool mUpdateWhenInvisible; // Update also when not visible
|
||||||
|
|
||||||
static bool _locked ;
|
static bool _locked ;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user