summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-12-11 19:49:50 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-12 03:26:39 +0100
commitc5c44e3a829d25227f623bd0e6211a4ff5d91b69 (patch)
tree811344b2aa21c163f7e655347ab7596f8be20ba0
parentb87cfa96660b09de359a70e5601039e67791c9c3 (diff)
downloadsubsurface-c5c44e3a829d25227f623bd0e6211a4ff5d91b69.tar.gz
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>
-rw-r--r--qt-ui/divelistview.cpp9
-rw-r--r--qt-ui/mainwindow.ui31
-rw-r--r--qt-ui/modeldelegates.cpp5
-rw-r--r--qt-ui/models.cpp4
-rw-r--r--subsurface.qrc2
5 files changed, 15 insertions, 36 deletions
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 <QMenu>
#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),
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 @@
<enum>Qt::Horizontal</enum>
</property>
<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">
<bool>true</bool>
</property>
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;
diff --git a/subsurface.qrc b/subsurface.qrc
index eb87675c5..a454d9d3b 100644
--- a/subsurface.qrc
+++ b/subsurface.qrc
@@ -31,4 +31,4 @@
<file alias="plan_minus">icons/planner/minus.png</file>
<file alias="plan_plus">icons/planner/plus.png</file>
</qresource>
- </RCC>
+ </RCC> \ No newline at end of file