Send counts to tray icon if available.
This commit is contained in:
parent
2943816804
commit
35497a55b7
@ -11,6 +11,7 @@
|
||||
#include "gui/messagesview.h"
|
||||
#include "gui/feedsview.h"
|
||||
#include "gui/statusbar.h"
|
||||
#include "gui/systemtrayicon.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QSplitter>
|
||||
@ -119,6 +120,15 @@ void FeedMessageViewer::updateAllFeeds() {
|
||||
}
|
||||
}
|
||||
|
||||
void FeedMessageViewer::updateCountsOfMessages(int unread_messages,
|
||||
int total_messages) {
|
||||
// TODO: Optimize the call isSystemTrayActivated()
|
||||
// because it opens settings (use member variable)?.
|
||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
||||
SystemTrayIcon::instance()->setNumber(unread_messages);
|
||||
}
|
||||
}
|
||||
|
||||
void FeedMessageViewer::onFeedUpdatesStarted() {
|
||||
FormMain::instance()->statusBar()->showProgress(0, tr("Feed update started"));
|
||||
}
|
||||
@ -152,6 +162,8 @@ void FeedMessageViewer::createConnections() {
|
||||
m_feedsView, SLOT(updateCountsOfSelectedFeeds()));
|
||||
connect(m_feedsView, SIGNAL(feedsNeedToBeReloaded(int)),
|
||||
m_messagesView, SLOT(reloadSelections(int)));
|
||||
connect(m_feedsView, SIGNAL(feedCountsChanged(int,int)),
|
||||
this, SLOT(updateCountsOfMessages(int,int)));
|
||||
|
||||
// Message openers.
|
||||
connect(m_messagesView, SIGNAL(openMessagesInNewspaperView(QList<Message>)),
|
||||
|
@ -40,7 +40,10 @@ class FeedMessageViewer : public TabContent {
|
||||
void updateSelectedFeeds();
|
||||
void updateAllFeeds();
|
||||
|
||||
protected slots:
|
||||
protected slots:
|
||||
// Updates counts of messages for example in tray icon.
|
||||
void updateCountsOfMessages(int unread_messages, int total_messages);
|
||||
|
||||
// Reacts on feed updates.
|
||||
void onFeedUpdatesStarted();
|
||||
void onFeedUpdatesProgress(FeedsModelFeed *feed, int current, int total);
|
||||
|
@ -160,12 +160,16 @@ void FeedsView::openSelectedFeedsInNewspaperMode() {
|
||||
}
|
||||
|
||||
void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) {
|
||||
foreach (FeedsModelFeed *feed, selectedFeeds()) {
|
||||
feed->updateCounts(update_total_too);
|
||||
}
|
||||
QList<FeedsModelFeed*> selected_feeds = selectedFeeds();
|
||||
|
||||
// Make sure that selected view reloads changed indexes.
|
||||
m_sourceModel->reloadChangedLayout(m_proxyModel->mapListToSource(selectionModel()->selectedRows()));
|
||||
if (!selected_feeds.isEmpty()) {
|
||||
foreach (FeedsModelFeed *feed, selected_feeds) {
|
||||
feed->updateCounts(update_total_too);
|
||||
}
|
||||
|
||||
// Make sure that selected view reloads changed indexes.
|
||||
m_sourceModel->reloadChangedLayout(m_proxyModel->mapListToSource(selectionModel()->selectedRows()));
|
||||
}
|
||||
}
|
||||
|
||||
void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
|
||||
@ -185,6 +189,10 @@ void FeedsView::updateCountsOfParticularFeed(FeedsModelFeed *feed,
|
||||
feed->updateCounts(update_total_too);
|
||||
m_sourceModel->reloadChangedLayout(QModelIndexList() << index);
|
||||
}
|
||||
|
||||
// TODO: Optimize this and call the signal in all updateCounts* methods.
|
||||
emit feedCountsChanged(m_sourceModel->rootItem()->countOfUnreadMessages(),
|
||||
m_sourceModel->rootItem()->countOfAllMessages());
|
||||
}
|
||||
|
||||
void FeedsView::initializeContextMenuCategoriesFeeds() {
|
||||
|
@ -93,6 +93,9 @@ class FeedsView : public QTreeView {
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
|
||||
signals:
|
||||
// Emitted if counts of messages are changed.
|
||||
void feedCountsChanged(int unread_messages, int total_messages);
|
||||
|
||||
// Emitted if currently selected feeds needs to be reloaded.
|
||||
void feedsNeedToBeReloaded(int mark_current_index_read);
|
||||
|
||||
|
@ -119,6 +119,7 @@ void SystemTrayIcon::show() {
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: Set better colors for number -> better readability.
|
||||
void SystemTrayIcon::setNumber(int number) {
|
||||
if (number < 0) {
|
||||
QSystemTrayIcon::setIcon(QIcon(m_normalIcon));
|
||||
|
Loading…
x
Reference in New Issue
Block a user