forked from qt-creator/qt-creator
ProjectTree: Do not use disabled state for disabled nodes
Rendering disabled nodes using the disabled state in the painter breaks themes as it introduces a discrepancy between the actual state of the node and its graphical representation. IIRC this was introduced since there was no easy way to find what color was supposed to be used for disabled items. That is no longer the case, so let's clean this up. Change-Id: Ic5653cd970e07eb680cb1d28d1feefd70aded540 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -88,7 +88,6 @@ public:
|
||||
enum ModelRoles {
|
||||
// Absolute file path
|
||||
FilePathRole = QFileSystemModel::FilePathRole,
|
||||
EnabledRole,
|
||||
isParsingRole
|
||||
};
|
||||
|
||||
|
@@ -89,6 +89,9 @@ FlatModel::FlatModel(QObject *parent)
|
||||
|
||||
for (Project *project : SessionManager::projects())
|
||||
handleProjectAdded(project);
|
||||
|
||||
m_disabledTextColor = Utils::creatorTheme()->color(Utils::Theme::TextColorDisabled);
|
||||
m_enabledTextColor = Utils::creatorTheme()->color(Utils::Theme::TextColorNormal);
|
||||
}
|
||||
|
||||
QVariant FlatModel::data(const QModelIndex &index, int role) const
|
||||
@@ -137,12 +140,12 @@ QVariant FlatModel::data(const QModelIndex &index, int role) const
|
||||
result = font;
|
||||
break;
|
||||
}
|
||||
case Project::FilePathRole: {
|
||||
result = node->filePath().toString();
|
||||
case Qt::TextColorRole: {
|
||||
result = node->isEnabled() ? m_enabledTextColor : m_disabledTextColor;
|
||||
break;
|
||||
}
|
||||
case Project::EnabledRole: {
|
||||
result = node->isEnabled();
|
||||
case Project::FilePathRole: {
|
||||
result = node->filePath().toString();
|
||||
break;
|
||||
}
|
||||
case Project::isParsingRole: {
|
||||
|
@@ -109,6 +109,8 @@ private:
|
||||
|
||||
QTimer m_timer;
|
||||
QSet<ExpandData> m_toExpand;
|
||||
QColor m_enabledTextColor;
|
||||
QColor m_disabledTextColor;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -93,12 +93,10 @@ public:
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
|
||||
{
|
||||
QStyleOptionViewItem opt = option;
|
||||
if (!index.data(Project::EnabledRole).toBool())
|
||||
opt.state &= ~QStyle::State_Enabled;
|
||||
QStyledItemDelegate::paint(painter, opt, index);
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
|
||||
if (index.data(Project::isParsingRole).toBool()) {
|
||||
QStyleOptionViewItem opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
ProgressIndicatorPainter *indicator = findOrCreateIndicatorPainter(index);
|
||||
|
||||
|
Reference in New Issue
Block a user