Commit aefa1485 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer Committed by con

Adapt a few hardcoded background colors in search results

Make the background of the files and line numbers adapt to the
background color. Making it darker only works nicely for non-dark
backgrounds, but it's better than hardcoding a light background.

The highlight of the search results still has to be fixed.
(cherry picked from commit 83974d89)
parent 2b233814
......@@ -91,7 +91,8 @@ int SearchResultTreeItemDelegate::drawLineNumber(QPainter *painter, const QStyle
cg = QPalette::Disabled;
painter->fillRect(lineNumberAreaRect, QBrush(isSelected ?
option.palette.brush(cg, QPalette::Highlight) : QBrush(qRgb(230, 230, 230))));
option.palette.brush(cg, QPalette::Highlight) :
option.palette.color(cg, QPalette::Base).darker(111)));
painter->setPen(isSelected ?
option.palette.color(cg, QPalette::HighlightedText) : Qt::darkGray);
painter->drawText(lineNumberAreaRect.adjusted(0, 0, -lineNumberAreaHorizontalPadding, 0),
......
......@@ -31,8 +31,10 @@
#include "searchresulttreeitems.h"
#include "searchresulttreeitemroles.h"
#include <QtGui/QApplication>
#include <QtGui/QFont>
#include <QtGui/QColor>
#include <QtGui/QPalette>
#include <QtCore/QDir>
using namespace Find::Internal;
......@@ -184,9 +186,11 @@ QVariant SearchResultTreeModel::data(const SearchResultFile *file, int role) con
switch (role)
{
case Qt::BackgroundRole:
result = QColor(qRgb(245, 245, 245));
case Qt::BackgroundRole: {
const QColor baseColor = QApplication::palette().base().color();
result = baseColor.darker(105);
break;
}
case Qt::DisplayRole:
result = QString(QDir::toNativeSeparators(file->fileName())
+ " (" + QString::number(file->childrenCount()) + ")");
......@@ -210,7 +214,7 @@ QVariant SearchResultTreeModel::data(const SearchResultFile *file, int role) con
}
QVariant SearchResultTreeModel::headerData(int section, Qt::Orientation orientation,
int role) const
int role) const
{
Q_UNUSED(section)
Q_UNUSED(orientation)
......@@ -222,7 +226,8 @@ void SearchResultTreeModel::appendResultFile(const QString &fileName)
{
m_lastAppendedResultFile = new SearchResultFile(fileName, m_rootItem);
beginInsertRows(QModelIndex(), m_rootItem->childrenCount(), m_rootItem->childrenCount());
const int childrenCount = m_rootItem->childrenCount();
beginInsertRows(QModelIndex(), childrenCount, childrenCount);
m_rootItem->appendChild(m_lastAppendedResultFile);
endInsertRows();
}
......
......@@ -38,13 +38,13 @@ using namespace Find::Internal;
SearchResultTreeView::SearchResultTreeView(QWidget *parent)
: QTreeView(parent)
, m_model(new SearchResultTreeModel(this))
, m_autoExpandResults(false)
{
m_model = new SearchResultTreeModel(this);
setModel(m_model);
setItemDelegate(new SearchResultTreeItemDelegate(this));
setIndentation(14);
setUniformRowHeights(true);
header()->hide();
connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(emitJumpToSearchResult(QModelIndex)));
......
......@@ -51,7 +51,6 @@ SearchResultWindow::SearchResultWindow()
m_widget->setWindowTitle(name());
m_searchResultTreeView = new SearchResultTreeView(m_widget);
m_searchResultTreeView->setUniformRowHeights(true);
m_searchResultTreeView->setFrameStyle(QFrame::NoFrame);
m_searchResultTreeView->setAttribute(Qt::WA_MacShowFocusRect, false);
m_widget->addWidget(m_searchResultTreeView);
......
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