Activity: When a new notification arrives, switch to that tab #4805

This commit is contained in:
Christian Kamm 2016-05-12 11:47:42 +02:00 committed by Christian Kamm
parent 194db066b6
commit a1ba23eea9
2 changed files with 18 additions and 1 deletions

View file

@ -248,6 +248,9 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList& list)
QHash<QString, int> accNotified;
QString listAccountName;
// Whether a new notification widget was added to the notificationLayout.
bool newNotificationShown = false;
foreach( auto activity, list ) {
if( _blacklistedNotifications.contains(activity)) {
qDebug() << Q_FUNC_INFO << "Activity in blacklist, skip";
@ -271,6 +274,7 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList& list)
_ui->_notifyScroll->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow);
#endif
_widgetForNotifId[activity.ident()] = widget;
newNotificationShown = true;
}
widget->setActivity( activity );
@ -365,6 +369,10 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList& list)
const QString log = tr("%1 Notifications - Action Required").arg(Theme::instance()->appNameGUI());
emit guiLog( log, msg);
}
if (newNotificationShown) {
emit newNotification();
}
}
void ActivityWidget::slotSendNotificationRequest(const QString& accountName, const QString& link, const QByteArray& verb)
@ -517,6 +525,7 @@ ActivitySettings::ActivitySettings(QWidget *parent)
connect(_activityWidget, SIGNAL(copyToClipboard()), this, SLOT(slotCopyToClipboard()));
connect(_activityWidget, SIGNAL(hideActivityTab(bool)), this, SLOT(setActivityTabHidden(bool)));
connect(_activityWidget, SIGNAL(guiLog(QString,QString)), this, SIGNAL(guiLog(QString,QString)));
connect(_activityWidget, SIGNAL(newNotification()), SLOT(slotShowActivityTab()));
_protocolWidget = new ProtocolWidget(this);
_tab->insertTab(1, _protocolWidget, Theme::instance()->syncStateIcon(SyncResult::Success), tr("Sync Protocol"));
@ -582,6 +591,13 @@ void ActivitySettings::slotShowIssueItemCount(int cnt)
_tab->setTabText(_syncIssueTabId, cntText);
}
void ActivitySettings::slotShowActivityTab()
{
if (_activityTabId != -1) {
_tab->setCurrentIndex(_activityTabId);
}
}
void ActivitySettings::slotCopyToClipboard()
{
QString text;

View file

@ -81,7 +81,7 @@ signals:
void copyToClipboard();
void rowsInserted();
void hideActivityTab(bool);
void newNotificationList(const ActivityList& list);
void newNotification();
private slots:
void slotBuildNotificationDisplay(const ActivityList& list);
@ -143,6 +143,7 @@ private slots:
void setActivityTabHidden(bool hidden);
void slotRegularNotificationCheck();
void slotShowIssueItemCount(int cnt);
void slotShowActivityTab();
signals:
void guiLog(const QString&, const QString&);