Kill the use of CSS - Fixes a Lot of issues on dark color schemes.

The css was done by me in the first days of subsurface for Qt, and it
was a code that I was never proud of. Mostly because I tougth at the
time that it was better to write it into CSS than to create a new class
just to take care of the size of the default cell height on a tree view.

Now I see that it was a biased approach since it created issues on
dark color schemes and it also didn't make a 'native' experience on
Gnome or OSX, only on KDE.

This fixes that.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2013-12-11 19:49:50 -02:00 committed by Dirk Hohndel
parent b87cfa9666
commit c5c44e3a82
5 changed files with 15 additions and 36 deletions

View file

@ -22,9 +22,18 @@
#include <QMenu> #include <QMenu>
#include <QFileDialog> #include <QFileDialog>
class DiveListDelegate : public QStyledItemDelegate{
public:
DiveListDelegate(){}
QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const {
return QSize(50,22);
}
};
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
sortColumn(0), currentOrder(Qt::DescendingOrder), searchBox(new QLineEdit(this)) sortColumn(0), currentOrder(Qt::DescendingOrder), searchBox(new QLineEdit(this))
{ {
setItemDelegate(new DiveListDelegate );
setUniformRowHeights(true); setUniformRowHeights(true);
setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate()); setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate());
QSortFilterProxyModel *model = new QSortFilterProxyModel(this); QSortFilterProxyModel *model = new QSortFilterProxyModel(this);

View file

@ -95,37 +95,6 @@
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<widget class="DiveListView" name="ListWidget"> <widget class="DiveListView" name="ListWidget">
<property name="styleSheet">
<string notr="true"> QTreeView {
show-decoration-selected: 1;
}
QTreeView::item {
border: 1px solid #d9d9d9;
border-top-color: transparent;
border-bottom-color: transparent;
padding: 2px;
}
QTreeView::item:hover {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
border: 1px solid #bfcde4;
}
QTreeView::item:selected {
border: 1px solid #567dbc;
}
QTreeView::item:selected:active{
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc);
}
QTreeView::item:selected:!active {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf);
}
</string>
</property>
<property name="alternatingRowColors"> <property name="alternatingRowColors">
<bool>true</bool> <bool>true</bool>
</property> </property>

View file

@ -41,12 +41,13 @@ void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
return; return;
int rating = value.toInt(); int rating = value.toInt();
int deltaY = option.rect.height()/2 - StarWidget::starActive().height() /2 ;
painter->save(); painter->save();
painter->setRenderHint(QPainter::Antialiasing, true); painter->setRenderHint(QPainter::Antialiasing, true);
for(int i = 0; i < rating; i++) for(int i = 0; i < rating; i++)
painter->drawPixmap(option.rect.x() + i * IMG_SIZE + SPACING, option.rect.y(), StarWidget::starActive()); painter->drawPixmap(option.rect.x() + i * IMG_SIZE + SPACING, option.rect.y() + deltaY, StarWidget::starActive());
for(int i = rating; i < TOTALSTARS; i++) for(int i = rating; i < TOTALSTARS; i++)
painter->drawPixmap(option.rect.x() + i * IMG_SIZE + SPACING, option.rect.y(), StarWidget::starInactive()); painter->drawPixmap(option.rect.x() + i * IMG_SIZE + SPACING, option.rect.y() + deltaY, StarWidget::starInactive());
painter->restore(); painter->restore();
} }

View file

@ -952,10 +952,10 @@ QVariant DiveItem::data(int column, int role) const
case DATE: /* fall through */ case DATE: /* fall through */
case SUIT: /* fall through */ case SUIT: /* fall through */
case LOCATION: case LOCATION:
retVal = Qt::AlignLeft; retVal = int(Qt::AlignLeft | Qt::AlignVCenter);
break; break;
default: default:
retVal = Qt::AlignRight; retVal = int(Qt::AlignRight | Qt::AlignVCenter);
break; break;
} }
break; break;