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/messagesview.h"
|
||||||
#include "gui/feedsview.h"
|
#include "gui/feedsview.h"
|
||||||
#include "gui/statusbar.h"
|
#include "gui/statusbar.h"
|
||||||
|
#include "gui/systemtrayicon.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QSplitter>
|
#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() {
|
void FeedMessageViewer::onFeedUpdatesStarted() {
|
||||||
FormMain::instance()->statusBar()->showProgress(0, tr("Feed update started"));
|
FormMain::instance()->statusBar()->showProgress(0, tr("Feed update started"));
|
||||||
}
|
}
|
||||||
|
@ -152,6 +162,8 @@ void FeedMessageViewer::createConnections() {
|
||||||
m_feedsView, SLOT(updateCountsOfSelectedFeeds()));
|
m_feedsView, SLOT(updateCountsOfSelectedFeeds()));
|
||||||
connect(m_feedsView, SIGNAL(feedsNeedToBeReloaded(int)),
|
connect(m_feedsView, SIGNAL(feedsNeedToBeReloaded(int)),
|
||||||
m_messagesView, SLOT(reloadSelections(int)));
|
m_messagesView, SLOT(reloadSelections(int)));
|
||||||
|
connect(m_feedsView, SIGNAL(feedCountsChanged(int,int)),
|
||||||
|
this, SLOT(updateCountsOfMessages(int,int)));
|
||||||
|
|
||||||
// Message openers.
|
// Message openers.
|
||||||
connect(m_messagesView, SIGNAL(openMessagesInNewspaperView(QList<Message>)),
|
connect(m_messagesView, SIGNAL(openMessagesInNewspaperView(QList<Message>)),
|
||||||
|
|
|
@ -41,6 +41,9 @@ class FeedMessageViewer : public TabContent {
|
||||||
void updateAllFeeds();
|
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.
|
// Reacts on feed updates.
|
||||||
void onFeedUpdatesStarted();
|
void onFeedUpdatesStarted();
|
||||||
void onFeedUpdatesProgress(FeedsModelFeed *feed, int current, int total);
|
void onFeedUpdatesProgress(FeedsModelFeed *feed, int current, int total);
|
||||||
|
|
|
@ -160,12 +160,16 @@ void FeedsView::openSelectedFeedsInNewspaperMode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) {
|
void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) {
|
||||||
foreach (FeedsModelFeed *feed, selectedFeeds()) {
|
QList<FeedsModelFeed*> selected_feeds = selectedFeeds();
|
||||||
feed->updateCounts(update_total_too);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure that selected view reloads changed indexes.
|
if (!selected_feeds.isEmpty()) {
|
||||||
m_sourceModel->reloadChangedLayout(m_proxyModel->mapListToSource(selectionModel()->selectedRows()));
|
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) {
|
void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
|
||||||
|
@ -185,6 +189,10 @@ void FeedsView::updateCountsOfParticularFeed(FeedsModelFeed *feed,
|
||||||
feed->updateCounts(update_total_too);
|
feed->updateCounts(update_total_too);
|
||||||
m_sourceModel->reloadChangedLayout(QModelIndexList() << index);
|
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() {
|
void FeedsView::initializeContextMenuCategoriesFeeds() {
|
||||||
|
|
|
@ -93,6 +93,9 @@ class FeedsView : public QTreeView {
|
||||||
void contextMenuEvent(QContextMenuEvent *event);
|
void contextMenuEvent(QContextMenuEvent *event);
|
||||||
|
|
||||||
signals:
|
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.
|
// Emitted if currently selected feeds needs to be reloaded.
|
||||||
void feedsNeedToBeReloaded(int mark_current_index_read);
|
void feedsNeedToBeReloaded(int mark_current_index_read);
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,7 @@ void SystemTrayIcon::show() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Set better colors for number -> better readability.
|
||||||
void SystemTrayIcon::setNumber(int number) {
|
void SystemTrayIcon::setNumber(int number) {
|
||||||
if (number < 0) {
|
if (number < 0) {
|
||||||
QSystemTrayIcon::setIcon(QIcon(m_normalIcon));
|
QSystemTrayIcon::setIcon(QIcon(m_normalIcon));
|
||||||
|
|
Loading…
Reference in New Issue