Add grey hint Activity entry if limit is reached
authorMichael Schuster <michael@schuster.ms>
Fri, 17 Jan 2020 19:26:48 +0000 (20:26 +0100)
committerMichael Schuster <michael@schuster.ms>
Fri, 17 Jan 2020 19:26:48 +0000 (20:26 +0100)
Signed-off-by: Michael Schuster <michael@schuster.ms>
src/gui/tray/ActivityListModel.cpp
src/gui/tray/ActivityListModel.h
src/gui/tray/Window.qml

index 8be9c174d025072052dfcbd263e3eea2667e5291..a9b2efc64381ca9b307c1295b096c66b4b3e3312 100644 (file)
@@ -50,6 +50,7 @@ QHash<int, QByteArray> ActivityListModel::roleNames() const
     roles[ActionRole] = "type";
     roles[ActionIconRole] = "icon";
     roles[ActionTextRole] = "subject";
+    roles[ActionTextColorRole] = "activityTextTitleColor";
     roles[ObjectTypeRole] = "objectType";
     roles[PointInTimeRole] = "dateTime";
     return roles;
@@ -170,6 +171,8 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
     }
     case ActionTextRole:
         return a._subject;
+    case ActionTextColorRole:
+        return a._id == -1 ? QLatin1String("#808080") : QLatin1String("#222");   // FIXME: This is a temporary workaround for _showMoreActivitiesAvailableEntry
     case MessageRole:
         if (a._message.isEmpty()) {
             return QString("No description available.");
@@ -185,7 +188,7 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
     case AccountRole:
         return a._accName;
     case PointInTimeRole:
-        return QString("%1 - %2").arg(Utility::timeAgoInWords(a._dateTime.toLocalTime()), a._dateTime.toLocalTime().toString(Qt::DefaultLocaleShortDate));
+        return a._id == -1 ? "" : QString("%1 - %2").arg(Utility::timeAgoInWords(a._dateTime.toLocalTime()), a._dateTime.toLocalTime().toString(Qt::DefaultLocaleShortDate));
     case AccountConnectedRole:
         return (ast && ast->isConnected());
     default:
@@ -279,6 +282,7 @@ void ActivityListModel::slotActivitiesReceived(const QJsonDocument &json, int st
         if(_totalActivitiesFetched == _maxActivities ||
             a._dateTime < oldestDate) {
 
+            _showMoreActivitiesAvailableEntry = true;
             _doneFetching = true;
             break;
         }
@@ -410,6 +414,22 @@ void ActivityListModel::combineActivityLists()
     if (_activityLists.count() > 0) {
         std::sort(_activityLists.begin(), _activityLists.end());
         resultList.append(_activityLists);
+
+        if(_showMoreActivitiesAvailableEntry) {
+            Activity a;
+            a._type = Activity::ActivityType;
+            a._accName = _accountState->account()->displayName();
+            a._id = -1;
+            a._subject = tr("For more activities please open the Activity app.");
+            a._dateTime = QDateTime::currentDateTime();
+
+            AccountApp *app = _accountState->findApp(QLatin1String("activity"));
+            if(app) {
+                a._link = app->url();
+            }
+
+            resultList.append(a);
+        }
     }
 
     beginResetModel();
@@ -444,6 +464,7 @@ void ActivityListModel::slotRefreshActivity()
     _doneFetching = false;
     _currentItem = 0;
     _totalActivitiesFetched = 0;
+    _showMoreActivitiesAvailableEntry = false;
 
     if (canFetchActivities()) {
         startFetchJob();
@@ -461,5 +482,6 @@ void ActivityListModel::slotRemoveAccount()
     _doneFetching = false;
     _currentItem = 0;
     _totalActivitiesFetched = 0;
+    _showMoreActivitiesAvailableEntry = false;
 }
 }
index 96b0785eea004783da2cb8e0801dfa781cbf5706..1c8ae6ee24e935c4b60464534a02190c57fcb32b 100644 (file)
@@ -45,6 +45,7 @@ public:
     ObjectTypeRole,
     ActionsLinksRole,
     ActionTextRole,
+    ActionTextColorRole,
     ActionRole,
     MessageRole,
     DisplayPathRole,
@@ -106,6 +107,7 @@ private:
     int _totalActivitiesFetched = 0;
     int _maxActivities = 100;
     int _maxActivitiesDays = 30;
+    bool _showMoreActivitiesAvailableEntry = false;
 };
 }
 
index 9fd16c82f0f7dee7e7619894b0e58ad6d025100c..5a040c9709898c001f898cef30c5f1a38c8a8c5d 100644 (file)
@@ -528,6 +528,7 @@ Window {
                         width: 240 + ((path === "") ? activityItem.height : 0) + ((link === "") ? activityItem.height : 0) - 8\r
                         elide: Text.ElideRight\r
                         font.pixelSize: 12\r
+                        color: activityTextTitleColor\r
                     }\r
 \r
                     Text {\r