Commit 220be9f3 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

Change color of feed title for error fetching status.

Change the color of title if a feed fails to be updated, which makes
the user easier to find feeds with errors in the list.

BUG: 150806
parent c8ee8fbd
Pipeline #83504 passed with stage
in 11 minutes and 14 seconds
......@@ -16,6 +16,7 @@
#include "akregator_debug.h"
#include <KLocalizedString>
#include <KColorScheme>
#include <QApplication>
#include <QByteArray>
#include <QDataStream>
......@@ -23,6 +24,7 @@
#include <QItemSelection>
#include <QList>
#include <QMimeData>
#include <QPalette>
#include <QStyle>
#include <QUrl>
#include <QVariant>
......@@ -168,6 +170,8 @@ Akregator::SubscriptionListModel::SubscriptionListModel(const QSharedPointer<con
connect(m_feedList.data(), &FeedList::fetchStarted, this, &SubscriptionListModel::fetchStarted);
connect(m_feedList.data(), &FeedList::fetched, this, &SubscriptionListModel::fetched);
connect(m_feedList.data(), &FeedList::fetchAborted, this, &SubscriptionListModel::fetchAborted);
m_errorColor = KColorScheme(QPalette::Normal, KColorScheme::View).foreground(KColorScheme::NegativeText).color();
}
int Akregator::SubscriptionListModel::columnCount(const QModelIndex &) const
......@@ -197,6 +201,8 @@ QVariant Akregator::SubscriptionListModel::data(const QModelIndex &index, int ro
return QVariant();
}
const Feed *const feed = qobject_cast<const Feed *const>(node);
switch (role) {
case Qt::EditRole:
case Qt::DisplayRole:
......@@ -209,11 +215,12 @@ QVariant Akregator::SubscriptionListModel::data(const QModelIndex &index, int ro
return node->totalCount();
}
break;
case Qt::ForegroundRole:
return feed && feed->fetchErrorCode() ? m_errorColor : QApplication::palette().color(QPalette::Text);
case Qt::ToolTipRole: {
if (node->isGroup() || node->isAggregation()) {
return node->title();
}
const Feed *const feed = qobject_cast<const Feed *const>(node);
if (!feed) {
return QString();
}
......@@ -226,7 +233,6 @@ QVariant Akregator::SubscriptionListModel::data(const QModelIndex &index, int ro
if (index.column() != TitleColumn) {
return QVariant();
}
const Feed *const feed = qobject_cast<const Feed *const>(node);
const auto iconSize = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
return feed && feed->isFetching() ? node->icon().pixmap(iconSize, QIcon::Active) : node->icon();
}
......@@ -239,7 +245,6 @@ QVariant Akregator::SubscriptionListModel::data(const QModelIndex &index, int ro
case IsAggregationRole:
return node->isAggregation();
case LinkRole: {
const Feed *const feed = qobject_cast<const Feed *const>(node);
return feed ? feed->xmlUrl() : QVariant();
}
case IsOpenRole: {
......
......@@ -13,6 +13,7 @@
#include <QSet>
#include <QSortFilterProxyModel>
#include <QColor>
#include <QSharedPointer>
namespace Akregator
......@@ -106,6 +107,8 @@ private Q_SLOTS:
private:
QSharedPointer<const FeedList> m_feedList;
bool m_beganRemoval;
QColor m_errorColor;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment