From c5c44e3a829d25227f623bd0e6211a4ff5d91b69 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 11 Dec 2013 19:49:50 -0200 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/divelistview.cpp | 9 +++++++++ qt-ui/mainwindow.ui | 31 ------------------------------- qt-ui/modeldelegates.cpp | 5 +++-- qt-ui/models.cpp | 4 ++-- 4 files changed, 14 insertions(+), 35 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 06b691c17..d77dd07aa 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -22,9 +22,18 @@ #include #include +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), sortColumn(0), currentOrder(Qt::DescendingOrder), searchBox(new QLineEdit(this)) { + setItemDelegate(new DiveListDelegate ); setUniformRowHeights(true); setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate()); QSortFilterProxyModel *model = new QSortFilterProxyModel(this); diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index 2261b4d04..60aa787e4 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -95,37 +95,6 @@ Qt::Horizontal - - 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); - } - - - true diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index b4b24b266..6cb47945a 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -41,12 +41,13 @@ void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o return; int rating = value.toInt(); + int deltaY = option.rect.height()/2 - StarWidget::starActive().height() /2 ; painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); 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++) - 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(); } diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index fffc79700..1faa46fb1 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -952,10 +952,10 @@ QVariant DiveItem::data(int column, int role) const case DATE: /* fall through */ case SUIT: /* fall through */ case LOCATION: - retVal = Qt::AlignLeft; + retVal = int(Qt::AlignLeft | Qt::AlignVCenter); break; default: - retVal = Qt::AlignRight; + retVal = int(Qt::AlignRight | Qt::AlignVCenter); break; } break; -- cgit v1.2.3-70-g09d2